Forum Moderators: phranque
I have been searching, reading, and learning all about SEO, 301 redirects, .htaccess, mod-rewrite, and all that good stuff for the past couple of days, and my frustrations are finally being resolved, except for (seemingly) one last road block.
I would like to create a mysite.com to www.mysite.com redirect to solve any canonical issues on my website (which is hosted through Verio which I believe is on an Apache server). As far as I know, I have to find my httpd.conf file and remove the '#' from the line 'LoadModule rewrite_module modules/mod_rewrite.so' in order to enable mod-rewrite so that I can apply the redirect code to my .htaccess file.
The problem: I cannot find the httpd.conf file in any of the directories on my server (i am using FileZilla). I can see and edit the .htaccess file (which I have and successfully created a regular 301 redirect from www.mysite.com/a to www.mysite.com/b) but from what I have read, you cannot employ the canonical redirect fix without enabling mod-rewrite.
Thanks again for any help regarding this issue.
Ian
Options +FollowSymLinks
RewriteEngine on
RewriteCond %{HTTP_HOST} ^mysite\.com
RewriteRule ^(.*)$ [mysite.com...] [R=permanent,L]
and
Options +FollowSymLinks
RewriteEngine On
RewriteCond %{HTTP_HOST} ^mysite\.com$ [NC]
RewriteRule ^(.*)$ [mysite.com...] [R=301,L]
to my .htaccess file, but when I go to mysite.com or [mysite.com,...] I am not redirected to www.mysite.com
Is there something I am missing?
Did you verify that you're on an Apache server?
Either code snippet should have worked, but I suggest that you do not end-anchor the hostname -- use the RewriteCond as shown in your first sample, not the second. Hostnames can have appended periods and port numbers, and only the first RewriteCond would redirect those.
Example: [google.com.:80...] is perfectly-valid, but non-canonical, and should be redirected to the "www" version.
Note: When debugging redirects, the "Live HTTP Headers" add-on for Firefox/Mozilla browsers is very useful. It will also tell you what kind of server you're hosted on, if the server is configured to send that info in the response headers (most are).
Jim
[edited by: jdMorgan at 4:29 pm (utc) on May 23, 2008]