I want to change URLs in one folder (cartoon
) in my site to friendly SEO URLs.
This folder (cartoon
) includes a PHP script not related to WordPress.
From:
example.com/cartoon/index.php?v=TitleEpisode
To:
example.com/cartoon/TitleEpisode
I read here all related questions but I did not benefit.
I have WordPress on my main domain (example.com
).
I found this code in .htaccess
file:
DirectoryIndex index.html index.php index.htm parking-page.html
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress
What do I do?
3
Answers
it's done. i enter this after the first line in .htaccess
thank u very much
Ok, based on the edit, it seems like what you want is for WordPress not to rewrite that slug but to ignore it.
You can do this by editing your
.htaccess
to exclude a folder. Make sure the folder is in the root directory of your site, as in, the same folder aswp-admin
,wp-content
, andwp-includes
.Then, open your
.htaccess
and add a rewrite rule to ignore that folder:OLD ANSWER
Well, this is fairly open-ended. For a better answer, please edit the question to include what you have already tried. Also, what do you mean by “one folder”? Is this a custom post type? Is it a category or custom taxonomy? Are there different permalinks for different types/taxonomies? Please provide more details on what you want to do.
But for the usual case, here is the documentation for pretty permalinks.
First, make sure
URL Rewriting
is enabled in Apache. Example in Ubuntu/DebianNow, in wp-admin, go to Settings -> Permalinks. Set the permalink to
Post Name
.Then click save changes. It will either save the new
.htaccess
automatically if your site has the permissions to, or it will give you the new content of.htaccess
to copy and paste.Now you should be able to view a post or page and it should show the SEO-friendly links.
How are you implementing (or intending to implement) the routing of
example.com/cartoon/TitleEpisode
?If this is entirely outside of WordPress then I would expect you to have an additional
.htaccess
file inside the/cartoon
subdirectory (since this is presumably a physical subdirectory)? This alone should be sufficient to override the WordPress mod_rewrite directives in the parent.htaccess
file, since mod_rewrite directives are not inherited by default.For instance, simply enabling the
RewriteEngine
in a subdirectory is sufficient to override the WP directives.In
/cartoon/.htaccess
:Then, in order to route a URL of the form
/cartoon/TitleEpisode
to/cartoon/index.php?v=TitleEpisode
, you would need something like:(A bit similar to the WP directives in the parent
.htaccess
file.)I would avoid editing between the
# BEGIN
and# END WordPress
markers in the parent.htaccess
file since these could be overridden by future WP updates.You would instead implement an exception before the WP directives. For example:
However, as mentioned above, you are probably better off creating an additional
.htaccess
file in the subdirectory and avoid touching the WordPress installation at all.