Forum Moderators: phranque
When performing an analysis via websitegrader I'm told that: "Permanent Redirect Not Found
Search engines often regard www.example.com and mysite.com as two different websites unless you take specific measures to signal to them that they are the same site. "
What I have is this redirect:
RewriteCond %{HTTP_HOST} ^.*$
RewriteRule ^/?$ http://www.example.com/oscommerce/ [R=301,L]
So what I want to achieve is that any call be it www.example.com, example.com, www.example.com/oscommerce, example.com/oscommerce all goes to www.example.com/oscommerce. This works from a user point fine, but seemingly there is a problem from a search engine point of view.
From another post I can see that this syntax should be good:
RewriteEngine On
RewriteCond %{HTTP_HOST} !^example.com$ [NC]
RewriteRule (.*) http://example.com/$1 [R=301,L]
To achieve the above objective, could anyone please advise exactly what to white in my .htaccess file?
Thanks :)
[edited by: jdMorgan at 6:20 pm (utc) on Dec. 23, 2007]
[edit reason] example.com [/edit]
# Redirect domain root to /oscommerce
RewriteRule ^$ http://www.example.com/oscommerce/ [R=301,L]
#
# Redirect all non-canonical domain requests to canonical domain
RewriteCond %{HTTP_HOST} !^www\.example\.com
RewriteRule (.*) http://www.example.com/$1 [R=301,L]
I deleted your first RewriteCond, since it wasn't doing anything at all except wasting CPU time.
You may also want to look into adding additional canonicalization rules -- For example, redirecting requests for /index.html (or index.php) to "/" -- What you may need depends on your site and the URLs it uses.
For more information, see the documents cited in our forum charter [webmasterworld.com] and the tutorials in the Apache forum section of the WebmasterWorld library [webmasterworld.com].
Jim
Also, would this have any implications for the usefulness of saved urls containing /oscommerce and not least search engine rankings?