What is this mod_rewrite doing?

Whether you are using Linux on the desktop or as a server, it's still good that you're using Linux. Linux related questions go here.

Moderator: General Moderators

Post Reply
alex.barylski
DevNet Evangelist
Posts: 6267
Joined: Tue Dec 21, 2004 5:00 pm
Location: Winnipeg

What is this mod_rewrite doing?

Post 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?
User avatar
JAB Creations
DevNet Resident
Posts: 2341
Joined: Thu Jan 13, 2005 6:44 pm
Location: Sarasota Florida
Contact:

Re: What is this mod_rewrite doing?

Post 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".
Post Reply