Reputation: 23
The RewriteRule ^(.*)$ FRAMEWORK.php?%
portion is showing up when I type a non www. Can someone help correct or advise why this is occurring.
I don't what the line is suppose to do. If I remove it the site won't load.
# Mod Rewrite
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ FRAMEWORK.php?%{QUERY_STRING}&resource=$1& [L]
# index redirect
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /([^/]+/)*index\.html\ HTTP/
RewriteRule ^(([^/]+/)*)index\.html$ http://%{HTTP_HOST}/$1 [R=301,L]
# non-www (non-canonical) to www
RewriteCond %{HTTP_HOST} !^(www\.|staging\.|$) [NC]
RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L]
</IfModule>
Upvotes: 0
Views: 48
Reputation: 96151
RewriteRule ^(.*)$ FRAMEWORK.php?%{QUERY_STRING}&resource=$1& [L]
After that rule is done, a new round of rewriting starts (that’s always the case when using rewriting within .htaccess).
# non-www (non-canonical) to www
RewriteCond %{HTTP_HOST} !^(www\.|staging\.|$) [NC]
RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L]
So when this rule es evaluated on the next round, the URL-path to rewrite is already FRAMEWORK.php
, so this is what $1
captures – and since this is an external redirect, it shows up in the address bar afterwards.
So you should switch the order of these two rules – rewrite non-www to www first. After that’s done, the redirect happens, so no more rewriting happens.
And then, when the new request reaches the server, the non-www condition is not true any more, and after that you should be able to rewrite to FRAMEWORK.php
without problems.
Upvotes: 1