Apache mod_rewrite Question
Posted: 2008-09-09 11:55am
Okay, so here's the skinny. In my top-level web root, I've got an .htaccess file that, among other things, has this in it:
The intent here is to redirect any request from "mcc3d.com/..." to "www.mcc3d.com/...". So far, so good. It works just fine.
Except...
...when I have another .htacess file, in a sub-directory. In this case, the top-level one is ignored in favor of the one in the sub-directory (which also uses mod_rewrite). This sub-directory holds a MediaWiki, and uses the following rule:
No problems there, either.
However, when I start trying to add the first mod_rewrite chunk to the second .htaccess file, it stops behaving as one might expect. The combined code I "expect" to work is:
But, using this brings up a "302 Found" page. What am I doing wrong?
Code: Select all
RewriteEngine On
RewriteCond %{HTTP_HOST} ^mcc3d.com$ [NC]
RewriteRule ^(.*)$ http://www.mcc3d.com/$1 [R,L]
Except...
...when I have another .htacess file, in a sub-directory. In this case, the top-level one is ignored in favor of the one in the sub-directory (which also uses mod_rewrite). This sub-directory holds a MediaWiki, and uses the following rule:
Code: Select all
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?title=$1 [PT,QSA,L]
However, when I start trying to add the first mod_rewrite chunk to the second .htaccess file, it stops behaving as one might expect. The combined code I "expect" to work is:
Code: Select all
RewriteEngine On
RewriteCond %{HTTP_HOST} ^mcc3d.com$ [NC]
RewriteRule ^(.*)$ http://www.mcc3d.com/$1 [PT,R,QSA]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?title=$1 [PT,QSA,L]