Forum Moderators: mack
"Once you've picked a root page and decided on www vs. non-www, make sure that all your links follow the same convention and point to the root page that you picked. Also, I would use a 301 redirect or rewrite so that your root page doesn't appear twice. For example, if you select [yourdomain.com...] as your root page, then if a spider tries to fetch [yourdomain.com...] (without the www), your web server should do a permanent (301) redirect to your root page at [yourdomain.com...]
First off, I'm not sure of the exact coding to do this. Examples on the web say to create a .htaccess file with coding like this:
redirect 301 /old/old.htm [domain.com...]
but not to use http:// in the first section after "redirect 301". If not, how exactly do you create the redirect that Googleguy suggests?
Also, on my web stats, I'm showing some requests for all of the "non-www" address versions of the pages in my site. Should these be 301 redirected too, or should I not worry about anything but my root page?
Thanks,
Mike
I copied the three lines of text you provided, changed "example" to my domain name in both lines, placed it in a plain text document, named it ".htaccess" and placed it on my ftp server. When I open a browser page and type in "http://mydomain.com", though, it doesn't redirect to "http://www.mydomain.com".
Could it be something on the hosting side that's not allowing it? (I'm using godaddy)
Thanks,
Mike
RewriteEngine on
RewriteCond %{HTTP_HOST} ^192\.168\.127\.1¦www\.example\.com¦example\.com\.$ [NC]
RewriteRule ^(.*)$ http://example.com/$1 [R=permanent,L]
As for godaddy, probably against TOS to say this, I signed up for their hosting service to see if it was any good. I decided to go for one month with the $10 package. They have a drop down box when your signing up on page one whether you want ASP/PHP. After going forward and backward through their horrendous signup process stuffed with ads I accidently got stuck with ASP. So I thought I would simply change it in their control panel. I couldn't find any way to change it. My choices would be to call them long distance and ask or email and maybe get a reply in a day. I figured this was a sign from gawd that I should just cut my losses. I cancelled my account five minutes after signing up. I lost my $10 but look at it as a lesson learned in cheap hosting.
First, always flush your browser cache (Temporary internet files) aftet making *any* changes to your configuration or access-control code. This forces the browser to send your request to the server where your code can have some effect, rather than serving your request from its locally-cached copy of the page.
Second, you may need to add the line
Options +FollowSymLinks
So with that and a few other fixes and speed-up tweaks, you get:
Options +FollowSymLinks
RewriteEngine on
RewriteCond %{HTTP_HOST} ^www\.example\.com¦192\.168\.127\.1 [NC]
RewriteRule (.*) http://example.com/$1 [R=301,L]
Change the broken pipe "¦" character above to a solid pipe before attempting to use this code; Posting on this forum modifies that character.
Jim