Multiple htaccess files

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

Multiple htaccess files

Postby DaveMcW » Thu May 14, 2009 1:52 pm

Is it possible to have two mod_rewrite rules in two .htaccess files at the same time?

For example,

/.htaccess
Code: Select all
RewriteEngine on
RewriteCond %{HTTP_HOST} ^www\.example\.com$
RewriteRule ^(.*)$ http://example.com/$1 [R=permanent,L]


/subfolder/.htaccess
Code: Select all
RewriteEngine on
RewriteRule ^test.txt$ source.txt [L]


So www.example.com/subfolder/test.txt points to example.com/subfolder/source.txt

Unfortunately, the /.htaccess rule seems to be ignored when I try this.
DaveMcW
 
Posts: 1
Joined: Wed May 13, 2009 9:12 am

Postby richardk » Fri May 15, 2009 8:47 am

Add
Code: Select all
RewriteOptions Inherit

to /subfolder/.htaccess.

Code: Select all
Options +FollowSymLinks

RewriteEngine On

RewriteCond %{HTTP_HOST} ^www\.example\.com$ [NC]
RewriteRule ^(.*)$ http://example.com/$1 [R=301,L]

Code: Select all
Options +FollowSymLinks

RewriteEngine On

RewriteOptions Inherit

RewriteRule ^test\.txt$ ./source.txt [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 7 guests

cron