Forum Moderators: phranque

Message Too Old, No Replies

Trying to redirect for canonical URLs.

Can't find where to enable mod-rewrite...

         

enthewhite

3:42 pm on May 23, 2008 (gmt 0)

10+ Year Member



First off, greetings to all forum members and thank you for any feedback you give me. (This is my first post :)

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

jdMorgan

3:47 pm on May 23, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



If you're on shared hosting, you will not be able to change server config files such as httpd.conf. But Verio/NTT shared Apache servers typically have mod_rewrite enabled.

All you may need to add ahead of your mod_rewrite code in .htaccess is


Options +FollowSymLinks
RewriteEngine on

Jim

enthewhite

3:52 pm on May 23, 2008 (gmt 0)

10+ Year Member



Thank you for the very quick reply! I will try it out and see what happens.

enthewhite

4:08 pm on May 23, 2008 (gmt 0)

10+ Year Member



Ok, I have tried adding both:

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?

jdMorgan

4:28 pm on May 23, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Did you completely flush your browser cache?

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]

enthewhite

4:42 pm on May 23, 2008 (gmt 0)

10+ Year Member



Awesome! I flushed my cache and it works now.

Thank you very much for your help, jdMorgan, I appreciate it :)

Now, off to tackle the google/adwords/SEO beast!