Nate Weiner

This is an old archived post from my former blog The Idea Shower. It's where I cataloged my product explorations and releases, one of which ultimately became Pocket.

This post was published back in 2008. It may not function as originally intended or may be missing images.

Override Wordpress Htaccess with Custom Rewrite Rules

September 09, 2008

I was working on a client project that used Wordpress as it's main method for content management.  In addition to Wordpress, it had a seperate admin/member area hosted on the same domain.  In this member area I had implemented several uses of Mod Rewrite to make cleaner urls.

However, when Wordpress was installed it's htaccess rules took over request, no matter what I had entered and in what order.

Here what my htaccess file looks like to allow other rewrite rules to run side by side with Wordpress:

<IfModule mod_rewrite.c>

RewriteEngine On RewriteBase /

RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_URI} !^/(file|member|photo) [NC] RewriteRule . /index.php [L]

RewriteRule ^member/([0-9]+)/ /member_profile.php?m=$1 RewriteRule ^file/([0-9]+)/(.+)? /file.php?f=$1 RewriteRule ^photo/([^/]+)/([^/]+)/(.+)? /file.php?type=$1&ref_id=$2&photo=1

</IfModule>

By adding the Rewrite Condition with Request URI, I'm able to add rules/folders that Wordpress should ignore.  Make sure you use Request_URI and not Request_Filename.  They provide two different results.