homepage Welcome to WebmasterWorld Guest from 54.197.110.151
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Pubcon Platinum Sponsor 2014
Home / Forums Index / Code, Content, and Presentation / Apache Web Server
Forum Library, Charter, Moderators: Ocean10000 & incrediBILL & phranque

Apache Web Server Forum

    
non-www/www and subdirectory
rhonda427

5+ Year Member



 
Msg#: 3533899 posted 3:33 pm on Dec 23, 2007 (gmt 0)

I have read a lot of threads about this subject, but still don't know how to tackle this situation :(

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]

 

jdMorgan

WebmasterWorld Senior Member jdmorgan us a WebmasterWorld Top Contributor of All Time 10+ Year Member



 
Msg#: 3533899 posted 6:19 pm on Dec 23, 2007 (gmt 0)

In example.com/.htaccess, I'd use:

# 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 can't say I agree with using an external redirect from "/" to /oscommerce/ -- An internal rewrite would seem to be more appropriate, and would "hide" the /oscommerce part of the URL. But I'm not sure if OSC would work properly that way -- Hopefully, someone else can comment on the intricacies of its installation and operation.

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

g1smd

WebmasterWorld Senior Member g1smd us a WebmasterWorld Top Contributor of All Time 10+ Year Member



 
Msg#: 3533899 posted 12:54 am on Dec 24, 2007 (gmt 0)

I always avoid redirectinhg from "/" to "/folder/" and much prefer to have a content page at "/".

If /folder/ contains a dynamic site, then "/" is usually a static page introducing the site and main navigation.

rhonda427

5+ Year Member



 
Msg#: 3533899 posted 7:32 am on Dec 24, 2007 (gmt 0)

Thanks for your replies. However, how do I make an "internal rewrite" so that it appears to the visitors that they always are in www.mysite.com and does not see www.mysite.com/oscommerce? I agree that the latter would be much better.

Also, would this have any implications for the usefulness of saved urls containing /oscommerce and not least search engine rankings?

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / Apache Web Server
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved