Multiple RewriteRules in Multiple .htaccess files

New to mod_rewrite? This is a good place to start.

Multiple RewriteRules in Multiple .htaccess files

Postby ben.greeley » Tue Aug 11, 2009 12:33 pm

I'm having an annoying issue where I have a .htaccess file on the / directory of my server that will have a script applied to all pages and directories. This works great except for when there is a directory with another .htaccess with its own RewriteRule in it. Has anybody ever run into this sort of issue before, and if so, how did you get around it?

Here is some sample code:

.htaccess (in /)
------------------
RewriteEngine on
RewriteBase /
RewriteRule ^(([^\/]*\/)+)_subsite_admin/(.*)$ /tools/admin/$3?calledfrom=%{SCRIPT_FILENAME}

.htaccess (in /subsite)
-------------------
RewriteEngine on
RewriteBase /subsite
RewriteRule ^search/(.*)$ search/index.cfm?search=$1\?%{QUERY_STRING} [NC,L]

Separately, they work fine (eg. when I disable one or the other), but together it breaks. If anybody could shed some light on the situation, that would rock!
ben.greeley
 
Posts: 1
Joined: Tue Aug 11, 2009 12:29 pm

Postby richardk » Wed Aug 12, 2009 12:02 pm

What _subsite_admin URLs are you trying?

Try
Code: Select all
Options +FollowSymLinks

RewriteEngine On

RewriteRule ^(.+)_subsite_admin/(.*)$ /tools/admin/$3?calledfrom=%{SCRIPT_FILENAME} [QSA,L]

and
Code: Select all
Options +FollowSymLinks

RewriteEngine On

RewriteCond %{ENV:REDIRECT_STATUS} ^$
RewriteRule ^search/(.*)$ search/index.cfm?search=$1\?%{QUERY_STRING} [NC,L]
richardk
 
Posts: 8800
Joined: Wed Dec 21, 2005 7:50 am


Return to Beginner's Corner

Who is online

Users browsing this forum: No registered users and 29 guests

cron