Nate Weiner

  • Archive
  • RSS

Override Wordpress Htaccess with Custom Rewrite Rules

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.

    • #htaccess
    • #mod-rewrite
    • #web-design
    • #wordpress
  • 3 years ago
  • Permalink
  • Share
    Tweet
← Previous • Next →

About

Prototyper, water waster, developer of Read It Later.

 

Follow

Twitter: @NateWeiner
Vimeo: Nate Weiner
500px: Nate Weiner
Blog: RSS

Pages

  • Contact
  • RSS
  • Random
  • Archive
  • Mobile

Effector Theme by Carlo Franco.

Powered by Tumblr