Forum Moderators: phranque

Message Too Old, No Replies

www.mysite.com, mysite.com question

         

tacheman

4:43 pm on Mar 13, 2004 (gmt 0)

10+ Year Member



My site was previously listed on google as "www.mysite.com" but now when I search google its listed under "mysite.com" instead. This seems to have coencided with it dropping way down the index(not sure if it's coincidence). My quiery is, how do I set my site up so that if somebody types in the URL "mysite.com" they get redirected to the URL "www.mysite.com"?

I've noted that most other sites automatically do this, however mine does not (but the site loads from both). I contacted the folks who host the site and they suggested using a redirect. After that failed they suggested using a mod_rewrite, but I'm not sure what that is.

As I say, I'm not sure if this'll explain my google problem but I'd like my site to be set up like the majority of other sites out there. Any advice will be much appreciated.

encyclo

5:46 pm on Mar 13, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



As your host mentioned using mod_rewrite, I assume you are using Apache - you need to create a plain text file called .htaccess in your document root, with the following:

Options +FollowSymLinks 
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} ^example\.com$
RewriteRule ^(.*)$ [example.com...] [R=301,L]

Note that if you already have an .htaccess file, you should add the following rather than overwriting it.

tacheman

7:19 pm on Mar 13, 2004 (gmt 0)

10+ Year Member



Thanks encyclo, that worked a treat. Not sure it'll make any difference to my search engine rankings.

wackal

11:37 pm on Mar 13, 2004 (gmt 0)

10+ Year Member



that should be a server setting, not something you have to add to your code. I don't know what the solution is, but I had the same problem when I switched web hosts and all I did was email tech support. It's something they have to configure on the server.

rogerdp

12:09 am on Mar 14, 2004 (gmt 0)

10+ Year Member



You should add [nocase] to the RewriteCond.

tacheman

10:20 am on Mar 14, 2004 (gmt 0)

10+ Year Member



Yeah, I thought it should be a server setting too and not something I should have to worry about. Seems OK now though.

Rodgerdp, can I ask what the [nocase] does?

rogerdp

8:08 pm on Mar 14, 2004 (gmt 0)

10+ Year Member



No, but you could read the documentation on RewriteCond. (You are double checking all advice and not using it blindly, right?) :P

The nocase flag makes the regex case-insensitive.