Welcome to WebmasterWorld Guest from 54.160.187.160

Forum Moderators: Ocean10000 & incrediBILL & phranque

Message Too Old, No Replies

How can I get them to be the same

www.domain.com diffrent than http://mydomain.com

     
6:56 pm on Nov 10, 2003 (gmt 0)

Junior Member

10+ Year Member

joined:Jan 5, 2003
posts:63
votes: 0


Grr, google is thinking that my site is diffrent with www. hence ranking it 2 times. I don't want to have any problems of duplicate content or anything like that, so is there any way (on my side) to make avoid this?

As always TIA,
Javi

12:58 am on Nov 11, 2003 (gmt 0)

New User

10+ Year Member

joined:June 11, 2003
posts:32
votes: 0

JVB, try putting this in your .htaccess file in your root web site directory (if you run Apache):

RewriteEngine on
RewriteCond %{HTTP_HOST} ^yourdomain.com$
RewriteRule ^(.+) http://www.yourdomain.com/$1 [L,R=301]

Make sure you test it right away - if you mess up your .htaccess file, then getting your site can be pretty screwed up. That should make it so going to http://yourdomain.com redirects immediately and permanently to http://www.yourdomain.com/

Scott

7:02 pm on Nov 11, 2003 (gmt 0)

Junior Member

10+ Year Member

joined:Jan 5, 2003
posts:63
votes: 0

Thanks Scott, that was very useful, so, if I wanted it the other way around (http://www. ---> http:// ) would it be:

RewriteEngine on
RewriteCond %{HTTP_HOST} ^www.yourdomain.com$
RewriteRule ^(.+) http://yourdomain.com/$1 [L,R=301]

TIA,
Javi

7:33 pm on Nov 11, 2003 (gmt 0)

Senior Member

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

joined:Mar 31, 2002
posts:25430
votes: 0


Yes, with some small corrections that apply to both versions:

RewriteEngine on
RewriteCond %{HTTP_HOST} ^www\.yourdomain\.com
RewriteRule ^(.*) http://yourdomain.com/$1 [L,R=301]

Ref: Introduction to mod_rewrite [webmasterworld.com]

Jim

[edited by: jdMorgan at 2:04 pm (utc) on Nov. 12, 2003]

10:36 pm on Nov 11, 2003 (gmt 0)

New User

10+ Year Member

joined:June 11, 2003
posts:32
votes: 0


Thanks jdMorgan, those corrections are right of course. Here's what they mean, in case anyone cares. (Assuming I have this right, please correct me if not, I'm just learning this stuff too):

The ^(.*) means 0 or more (*) characters of any kind (.), at the start of the line. (Rather than + which is one or more)

The \. escapes the . to mean . instead of 'any character'.

I'm not sure why the $ can't be at the end of the HTTP_HOST line, as the .com SHOULD end it - what could go after?

Scott

11:01 pm on Nov 11, 2003 (gmt 0)

Junior Member

10+ Year Member

joined:Jan 5, 2003
posts:63
votes: 0


Thnx again! You guys are great :)
11:04 pm on Nov 11, 2003 (gmt 0)

Senior Member

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

joined:Mar 31, 2002
posts:25430
votes: 0


Scott,

A port number is one I've had mess me up when the hostname is end-anchored. I just got in the habit of leaving it off because of that. e.g. http://www.example.com:8080

Jim

10:11 am on Nov 12, 2003 (gmt 0)

Full Member

joined:Nov 9, 2003
posts:216
votes: 0


Great advice:

<snip snip snip etc!>

<my edit: question already answered in Introduction to mod rewrite>

[edited by: superscript at 12:08 pm (utc) on Nov. 12, 2003]

10:44 am on Nov 12, 2003 (gmt 0)

Full Member

joined:Nov 9, 2003
posts:216
votes: 0


Hi,

I just tried uploading this to my root directory:

RewriteEngine on
RewriteCond %{HTTP_HOST} ^yourdomain\.co\.uk
RewriteRule ^(.*) http://www.yourdomain.co.uk/$1 [L,R=301]

On testing the site was down with an internal server error on both www and non-www.

Can anyone advise / see any mistakes in it?

(intention is all non-www to www)

[edited by: jdMorgan at 2:04 pm (utc) on Nov. 12, 2003]
[edit reason] De-linked [/edit]

1:49 pm on Nov 12, 2003 (gmt 0)

Senior Member

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

joined:Mar 31, 2002
posts:25430
votes: 0


superscript,

Try adding


Options +FollowSymLinks

at the top of the code, before RewriteEngine on.

Some server setups need this, and some don't. If it still does not work, contact your host admin and ask them if mod_rewrite is accessible to you and whether you have sufficient priveleges to use it. At minimum, you will need AllowOverride FileInfo to use mod_rewrite. AllowOverride All is better. Only your host admin can change these AllowOverride settings.

Jim

2:25 pm on Nov 12, 2003 (gmt 0)

Senior Member

WebmasterWorld Senior Member 10+ Year Member

joined:Dec 2, 2002
posts:1167
votes: 0


> Options +FollowSymLinks

It's not in my htaccess, but all rewrites and redirects work fine, so I haven't fretted much.

I do have one curiosity on the above though. On (fairly rare) occasion, an ip rolls in attempting to access a non-existent FP extension directory, e.g., domain.tld/_vti_bin , and it gets a 403 served due to +FollowSymLinks not being present.

That doesn't seem to be a bad thang though, so I've left well enough alone. Should I be more interested than I've been to date?

7:56 pm on Nov 12, 2003 (gmt 0)

Full Member

joined:Nov 9, 2003
posts:216
votes: 0


Hi jdMorgan,

Many thanks

I've added the code as suggested - no joy - same 500 error. I've contacted my hosts, but they don't seem to understand what I'm trying to do.

5:42 pm on Nov 26, 2003 (gmt 0)

New User

10+ Year Member

joined:Nov 26, 2003
posts:2
votes: 0


This worked very well for me, except for one hitch. With IE, changing site.com/ to www.site.com/ causes IE to translate the "/" to "/index.php". If I try remapping index.php to /, I get a looping error :)

Any ideas?

6:06 pm on Nov 26, 2003 (gmt 0)

Senior Member

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

joined:Mar 31, 2002
posts:25430
votes: 0


kevinpate,

That 403 means access was forbidden, so some other mechanism blocked access.

superscript,

Have a look at your raw error log file to see if there is any indication of the problem there.

It sounds like your server may not support mod_rewrite.
Here's a simple test: Create an .htaccess file like this:


Options +FollowSymLinks
RewriteEngine on
RewriteRule ^silly\.html$ /index.html [L]

"silly.html" must be a page name that does not exist on your site, and "index.html" is the name of your home page.
Now request www.yourdomain.com/silly.html with your browser, and you should see your home page.
If it doesn't work, you need to ask your hosting provider for help. If they can't help, you may need a new provider.

svardaman,

Welcome to WebmasterWorld [webmasterworld.com]!

Unless it's a caching issue (flush your temp files), that's probably not IE changing the path. It's most likely a config setting on the server.

What is the full name of your index page? Is it "index.html"? If so, perhaps adding this line would fix the problem:


DirectoryIndex index.html

Jim

12:40 am on Nov 27, 2003 (gmt 0)

New User

10+ Year Member

joined:Nov 26, 2003
posts:2
votes: 0


Thanks. I tried directoryindex (in my case it's index.php), and on a PC that's never visited the site, but no luck. And it's just with the index.php file on the root dir. I can't understand it.

Until I do, I'm just going to do a redir in PHP.

Thanks!