Forum Moderators: phranque

Message Too Old, No Replies

Question regarding my htaccess code

i dont know much about htaccess

         

dailypress

9:02 pm on Mar 21, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I read the following thread:
[webmasterworld.com...]
and although I really dont understand the code, I copy/paste some of it.

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.

jdMorgan

12:08 am on Mar 22, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



That code won't work outside the framework provided in the original thread.

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

dailypress

2:46 pm on Mar 22, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



thanks jdMorgan.
so for now I only included the non-www to www. redirect! is that ok? and it does work.

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