Link to home
Start Free TrialLog in
Avatar of webdirexion
webdirexion

asked on

Best way to understand Apache Rewrite Implications

Hi -

A client has the following rewrite code in his .htaccess file:
RewriteCond %{HTTP_HOST} !^www\.
RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L]

Open in new window


I would like to :
a) translate each line into an understanding of what the code does (ie. last line means something like "wildcard redirect all links to this domain to the home page", and I think the first line is about forcing www to be in the domain name.  );

b) understand the options to change it should we judge it to be not the best rewrite for SEO.  Here, I am wondering if someone can point us at a good reference for those that don't write apache code often.

Final question:  what if the domain is going to https -- must that be described in this code?

Thanks -
Scott
ASKER CERTIFIED SOLUTION
Avatar of Lucas Bishop
Lucas Bishop
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Since you do not seem to have any checks for ports (80 vs. 443) I think that if somebody enter https://yoursite.com  they would be redirected to http://www.yoursite.com.

However, if they entered https://www.yoursite.com, there would be no re-write because the hostname starts with www.
Avatar of webdirexion
webdirexion

ASKER

This was a well-crafted answer.  Thanks.