Forum Moderators: phranque
When you type example.com it does FW to www.example.com however I couldnt really see the rest of it working!
any idea why the rest doesnt work? for example Why didnt example.com/index.hmtl redirect to www.example.com/index.html?
RewriteEngine On
RewriteCond %{HTTP_HOST} ^example\.com
RewriteRule (.*) http://www.example.com/$1 [R=301,L]
RewriteCond %{ENV:myURI} ^([^.,]+)[.,]+hmtl [NC]
RewriteRule . - [E=qRed:yes,E=myURI:%1.html]
RewriteCond %{ENV:myURI} ^([^,.]+)([,.]{2,}¦,)((s?html?¦php[1-9]?¦pdf¦xls).*)$ [NC]
RewriteRule . - [E=qRed:yes,E=myURI:%1.%3]
RewriteCond %{ENV:myURI} ^([/0-9a-z._\-]*)[^/0-9a-z._\-] [NC]
RewriteRule . - [E=qRed:yes,E=myURI:%1]
RewriteCond %{ENV:myURI} ^([^.]+\.[^/]+)/
RewriteRule . - [E=qRed:yes,E=myURI:%1]
RewriteCond %{ENV:myURI} ^(.*)[._\-]+$
RewriteRule . - [E=qRed:yes,E=myURI:%1]
RewriteCond %{ENV:myURI} ^(.*)//+(.*)$
RewriteRule . - [E=qRed:yes,E=myURI:%1/%2,C]
RewriteCond %{ENV:myURI} ^(.*)//+(.*)$
RewriteRule . - [E=myURI:%1/%2,C]
RewriteCond %{ENV:myURI} ^(.*)//+(.*)$
RewriteRule . - [E=myURI:%1/%2]
RewriteCond %{ENV:myURI} ^(/([^/]+/)*)index\.html [NC]
RewriteRule . - [E=qRed:yes,E=myURI:%1]
RewriteCond %{ENV:myQS} ^\?$
RewriteRule .? - [E=qRed:yes,S=1]
thanks in advance.
In short, you can't copy and paste htaccess code without understanding it -- It is not good for the health of your server.
For more information, see the documents cited in our forum charter [webmasterworld.com] and the tutorials in the Apache forum section of the WebmasterWorld library [webmasterworld.com].
Jim