Add Custom Rules to WordPress .htaccess
WordPress uses a .htaccess file to rewrite all the URLs to look like “http://www.kingrosales.com/category/internet-marketing/” rather than “http://www.kingrosales.com/index.php?pageid=10″.
By default, a WordPress .htaccess file looks like:
# BEGIN wordpress
<ifmodule mod_rewrite.c>
rewriteEngine On
rewriteBase /
rewriteCond %{REQUEST_FILENAME}!-f
rewriteCond %{REQUEST_FILENAME}!-d
rewriteRule . /index.php [L]
</ifmodule>
# END wordpress
When I had to install a custom application under a non-wordpress directory and wanted to rewrite those URLs, I would always get a “Error 404 – Page Not Found” from WordPress & any custom non-wordpress related rules I was writing wouldn’t work.
Solution:
If you want to add custom .htaccess non wordpress rules, simply enclose your custom rules between a new “<ifmodule mod_rewrite.c>…</ifmodule> and have it positioned above the exisiting WordPress rules:
# My Custom Rules
<ifmodule mod_rewrite.c>
rewriteEngine On
... Your Custom Rules Here...
</ifmodule>
# End Custom Rules
# BEGIN wordpress
<ifmodule mod_rewrite.c>
rewriteEngine On
rewriteBase /
rewriteCond %{REQUEST_FILENAME}!-f
rewriteCond %{REQUEST_FILENAME}!-d
rewriteRule . /index.php [L]
</ifmodule>
# END wordpress
And that’s it! Happy Rewriting



Could you please give me an example custom htaccess code for adding non wp directory?
I’ve tried but still have 404 error
This does not work – 404 page is always returned
def. didnt’ work.
Like the others, this also DIDN’T work for me.
Leave your response!
Connect
Get Updates by Email
Recent Posts
Links
Archives
Topics
About Me
Blogroll