View Full Version : With and without WWW
nadlay
Jun 20th 2004, 8:45 am
I've seen mention several times about PR being different for domain.com and www.domain.com
Several commentators mentioned that this is because the search engines consider them each as different URLs.
Before I came on this forum, I didn't even know you could have a domain without the WWW.
How are such domains created?
With all my domains, I have just created the account using WHM (Web Host Manager) and normally just put in domain.com in the domain box.
Does this mean that all my domains should really be referenced as domain.com rather than www.domain.com?
OR, have I got the worng end of the stick completely, and, as long as I consistently use www.domain.com in any backlinks, it isn't going to be relevant?
digitalpoint
Jun 20th 2004, 9:31 am
In Apache, you would simply configure it as a different site. And you would of course need a DNS entry for it as well.
schlottke
Jun 20th 2004, 10:05 am
basically www.domain.com and domain.com are the same thing (if you dont have them seperated.) if you have all of your links going to one or the other.
Question for Shawn- How can you redirect a domain.com to www.domain.com so the PR from sites linking to that transfers over?
dsr771
Jun 20th 2004, 10:36 am
The WHM server usually configures Apache so that your domain will work with and without the www. For best PR, you should pick one and always use the same form for all links and backlinks.
vinyl
Jun 20th 2004, 12:04 pm
schlottke, let me take that down from shawns back :)
you can use apaches mod_rewrite and setup 301 redirection rule.
for instance, something like:
RewriteEngine On
Options +FollowSymlinks
RewriteBase /
RewriteCond %{HTTP_HOST} ^digitalpoint\.com
RewriteRule ^(.*)$ http://www.digitalpoint.com/$1 [R=permanent]
in .htaccess should do the job.
Owlcroft
Jun 20th 2004, 2:38 pm
Such a redirect, from the "deprecated" form to the "preferred" form (and which is which does not matter, just pick one) is something that every single website absolutely, positively should have in place.
This is the third time just today that I have had occasion to post that, across two forums, so I guess it's not as nearly universal knowledge as it should be.
ResaleBroker
Jul 4th 2004, 3:58 pm
[QUOTE=Owlcroft]Such a redirect, from the "deprecated" form to the "preferred" form (and which is which does not matter, just pick one) is something that every single website absolutely, positively should have in place.
After reading several different posts on this matter I'm sold. Now I just need to make sure I understand this right. I can set up a 301 redirect with either:
mod_rewrite in a .htaccess file
RewriteEngine On
Options +FollowSymlinks
RewriteBase /
RewriteCond %{HTTP_HOST} ^resalebroker\.com
RewriteRule ^(.*)$ http://www.resalebroker.com/$1 [R=permanent]
or the following code in a .htaccess file?
redirect 301 http://resalebroker*com http://www.resalebroker*com
Is that right? :confused:
l0cke
Jul 4th 2004, 5:26 pm
mod_rewrite in a .htaccess file
RewriteEngine On
Options +FollowSymlinks
RewriteBase /
RewriteCond %{HTTP_HOST} ^resalebroker\.com
RewriteRule ^(.*)$ http://www.resalebroker.com/$1 [R=permanent]
or the following code in a .htaccess file?
redirect 301 http://resalebroker*com http://www.resalebroker*com
Is that right? :confused:Try this:
RewriteEngine On
RewriteCond %{HTTP_HOST} ^resalebroker.com
RewriteRule (.*) http://www.resalebroker.com/$1 [R=301,L]
Works for me..
compar
Jul 4th 2004, 5:54 pm
The way we do it on our FreeBSD/Apache server is to simply set up a symbolic link at the O/S level so that if anyone tries to enter domain.com they are taken to the content of www.domain.com. But we are very careful to have all links internal and external point only to the "www" version.
john_loch
Jul 5th 2004, 3:58 am
I've seen mention several times about PR being different for domain.com and www.domain.com
Several commentators mentioned that this is because the search engines consider them each as different URLs.
Before I came on this forum, I didn't even know you could have a domain without the WWW.
How are such domains created?
With all my domains, I have just created the account using WHM (Web Host Manager) and normally just put in domain.com in the domain box.
Does this mean that all my domains should really be referenced as domain.com rather than www.domain.com?
OR, have I got the worng end of the stick completely, and, as long as I consistently use www.domain.com in any backlinks, it isn't going to be relevant?
Yep - consistency with linking will take care of it. But it pays to cover the bases just the same..
Actually, if you take a look at your cpanel acct (as created under WHM) and open the file manager, you'll find that www is treated as a subdomain. It lives in acct root as a sym link (represented as a folder (www) in the file manager). So, you can reference your domains either as wxyz.com or www.xyz.com. The trick is to ensure that all links to your domain are either one OR the other. I'd be inclined to use mod_rewrite to redirect from wxyz.com to www.wxyz.com - there's plenty of info around on how to script mod_rewrite. :)
Owlcroft
Jul 6th 2004, 3:21 pm
The crucial thing, I reckon, is that a 301 Redirect be issued by any call to the "wrong" URL form.
The point is not to make sure that the visitor (or searchbot) finds your site--it would be rare for a call to one form not to "reach" the other--but that the searchbots see a 301 for the deprecated form, so that links from others (whose exact form we can never fully control) are all "counted" against the preferred URL form.
ResaleBroker
Jul 6th 2004, 11:20 pm
Try this:
RewriteEngine On
RewriteCond %{HTTP_HOST} ^resalebroker.com
RewriteRule (.*) http://www.resalebroker.com/$1 [R=301,L]
Works for me..
Thank You! This is working great. I appreciate the help.
kuhleen
Sep 8th 2004, 11:22 am
there is a simple PHP fix to the duplicated www. domain.com -> domain.com content problem on php9.com
shacker
Dec 12th 2005, 9:04 am
I think it's been the default behavior for many years at almost all web hosts to make domains accessible with or without the www. What surprises me in reading this thread is that the posted redirect rules reroute TO the www version rather than the other way around. www should be preserved for the few people out there who still habitually type www in front of everything, but I'd think the version without www would by far be the preferred form for its elegance and simplicity.
Roman
Dec 12th 2005, 9:14 am
Just thought I'd mention this as I had a hard time finding it. If you want to use the non-www of your site place this into the .htaccess file of your www folder and your public_html folder:
RewriteEngine on
RewriteCond %{HTTP_HOST} !^sitename\.com
RewriteRule ^.*$ http://sitename.com%{REQUEST_URI} [R=301,L]
****note: replace sitename with your site name, leave out the http:// and the www
Ellen C. Braun
Dec 12th 2005, 9:37 am
Wow, great post!
This explains why http://www.yourfamily1st.com/ has PR 4 (I always use that format in my linking) and http://yourfamily1st.com has PR 0!
wakeup
Mar 10th 2006, 3:06 am
Hi, I use in my web this .htacces
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} !^www\.hhdirecto\.net [NC]
RewriteRule ^(.*) http://www.hhdirecto.net/$1 [L,R=301]
It run ok, but when I have a folder with another .htacces it don't do anything.
thanks
Tam
Mar 11th 2006, 3:18 am
Use this ...
RewriteEngine on
RewriteCond %{HTTP_HOST} ^([^.]+\.com) [NC]
RewriteRule (.*) http://www.%1/$1 [R=301,L]
It will redirect any request for any page without the www to the corresponding page with the www.
:)
wakeup
Mar 13th 2006, 6:15 am
I have tried it but when I go to
hhdirecto.net/letras it redirect to
www.hhdirecto.net//www/h/h/hhdirecto.net/htdocs/letras
:(
Tam
Mar 13th 2006, 9:42 am
Who's post are you replying too?
I should have added that you should place the .htaccess file in your web root (the folder which holds all of your web pages).
wakeup
Mar 13th 2006, 11:24 am
Who's post are you replying too?
I should have added that you should place the .htaccess file in your web root (the folder which holds all of your web pages).
The reply was for you.
I have just tried it, I have put it in my root htaccess file, and it is the same result. It redirect hhdirecto.net/breakdance to www.hhdirecto.net/breakdanc, but Don't redirect hhdirecto.net/letras to www.hhdirecto.net/letras because letras have another .htacces file
RewriteEngine On
RewriteRule ^.+-a([0-9]*)\.html album.php?id=$1
RewriteRule ^.+-t([0-9]*)\.html track.php?id=$1
:(
Tam
Mar 14th 2006, 2:16 am
Try placing it in that htaccess file instead, but after the existing code you've shown above - let us know how it goes.
wakeup
Mar 14th 2006, 12:11 pm
Try placing it in that htaccess file instead, but after the existing code you've shown above - let us know how it goes.
neither :(
I have just tried this in my forder .htacces file
RewriteEngine On
RewriteRule ^.+-a([0-9]*)\.html album.php?id=$1
RewriteRule ^.+-t([0-9]*)\.html track.php?id=$1
RewriteCond %{HTTP_HOST} ^([^.]+\.net) [NC]
RewriteRule (.*) http://www.%1/$1 [R=301,L]
dealsway
Mar 17th 2006, 12:08 pm
Hi Tam,
I used your code ,
it doesn't seem to redirect the files without www init.
what could be the issue?
Tam
Mar 17th 2006, 1:22 pm
neither :(
I have just tried this in my forder .htacces file
RewriteEngine On
RewriteRule ^.+-a([0-9]*)\.html album.php?id=$1
RewriteRule ^.+-t([0-9]*)\.html track.php?id=$1
RewriteCond %{HTTP_HOST} ^([^.]+\.net) [NC]
RewriteRule (.*) http://www.%1/$1 [R=301,L]
hmmm, looks as though you are running some sort of script?
Since I don't know the script, or if you can configure it to point to www.yourdomain, maybe it would be easier to place that script in a subdomain and use the original htaccess for your main domain?
Tam
Mar 17th 2006, 1:29 pm
Hi Tam,
I used your code ,
it doesn't seem to redirect the files without www init.
what could be the issue?
You need to place it in your main web folder (often 'public_html'), maybe you have placed it somewhere else? Does your host allow you to use htaccess?
Just a quick explanation of what it does ...
RewriteCond %{HTTP_HOST} ^([^.]+\.com) [NC]
This line checks to make sure it's not a www or subdomain request, before running the next line ...
RewriteRule (.*) http://www.%1/$1 [R=301,L]
This line redirects the request to the corresponding page but with the www prefix.
Tam
Mar 17th 2006, 1:34 pm
neither :(
I have just tried this in my forder .htacces file
RewriteEngine On
RewriteRule ^.+-a([0-9]*)\.html album.php?id=$1
RewriteRule ^.+-t([0-9]*)\.html track.php?id=$1
RewriteCond %{HTTP_HOST} ^([^.]+\.net) [NC]
RewriteRule (.*) http://www.%1/$1 [R=301,L]
As a matter of interest what was the result? The same as your previous post or in some way different?
dealsway
Mar 17th 2006, 1:52 pm
Hi Tam, it works for folder and its not working for files. so still do you think we are having issue in running .htaccess or we are not in the root of the public_html
Tam
Mar 17th 2006, 1:55 pm
Hi Tam, it works for folder and its not working for files. so still do you think we are having issue in running .htaccess or we are not in the root of the public_html
Can you give any examples?
I am going to have to go for a while but will try and get back later, failing that, I'll be back in the morning. Sorry about that.
:)
dealsway
Mar 18th 2006, 10:01 am
My hosting poeple also not sure why the code is not working.
Can you guys tell me whether the following code is okay so that i can make sure that this is done with all our files.
if($_SERVER["HTTP_HOST"] == "domain.com") {
$URI = $_SERVER["REQUEST_URI"];
Header( "HTTP/1.1 301 Moved Permanently" );
Header( "Location: http://www.domain.com$URI" );
exit();
}
Tam
Mar 18th 2006, 10:33 am
My hosting poeple also not sure why the code is not working.
Can you guys tell me whether the following code is okay so that i can make sure that this is done with all our files.
if($_SERVER["HTTP_HOST"] == "domain.com") {
$URI = $_SERVER["REQUEST_URI"];
Header( "HTTP/1.1 301 Moved Permanently" );
Header( "Location: http://www.domain.com$URI" );
exit();
}
Yes that works, but don't forget to change the domain.com element to your own domain. Its also a search engine friendly way of doing it, apparently. You just have to place it at the very beginning of every page, and every page has to be a .php page
Glad you sorted it :)
dealsway
Mar 18th 2006, 3:03 pm
yes, all are PHP files and i was lucky that i had a common file which was included in all our PHP files as first file, so i just put this code and everything went well.
now both for folders and for files we are having the 301 redirect.
Tam
Mar 18th 2006, 3:22 pm
That's great!
Look forward to seeing how things are going in the future, good luck m8 :)
dealsway
Mar 18th 2006, 9:15 pm
Sure, i will share the results soon.
Tam
Mar 19th 2006, 4:02 am
I should have added to my other post, that htere is a way to force your server to read html files as php files, but that also relies on an htaccess entry, so that may or may not be available to you (just as the problem with the htaccess mod_rewrite we tried before).
If you want to try that at any time just add the following to the top of your htaccess file ...
AddType application/x-httpd-php .html
:)
johneva
Mar 19th 2006, 6:21 am
Use this ...
RewriteEngine on
RewriteCond %{HTTP_HOST} ^([^.]+\.com) [NC]
RewriteRule (.*) http://www.%1/$1 [R=301,L]
It will redirect any request for any page without the www to the corresponding page with the www.
:)
I have just used this thanx it work great, just the job. :)
wakeup
Mar 20th 2006, 12:42 am
hmmm, looks as though you are running some sort of script?
What kind of script have I to search? php script?
vBulletin® v3.6.8, Copyright ©2000-2008, Jelsoft Enterprises Ltd.