Page 1 of 1

What is this mod_rewrite doing?

Posted: Tue Mar 24, 2009 1:53 pm
by alex.barylski

Code: Select all

RewriteEngine On
RewriteCond %{HTTP_HOST} !^www\.domain\.com$
RewriteRule ^(.*)$ http://www.domain.com/$1 [R=301]
# % { SERVER _ NAME } 
php_value session.cookie_domain ".domain.com"
When I remove this .htaccess file the root the pages stop delivering...is it redirecting to 'www' sub-domain when no sub-domain is given?

Re: What is this mod_rewrite doing?

Posted: Thu Mar 26, 2009 7:58 am
by JAB Creations
It sort of looks like a non-www redirect to www. Apache is still mostly a mystery as far as writing what I want with it though. Go to where you got the code (or plug it in to your favorite search engine) and see what people are saying in regards to that snippet.

In regex though ^ means "starts with" and $ means "ends with".