View Full Version : no http://example.com yes http://www.example.com
thenewguy
08-08-2006, 12:00 AM
http://www.google.com/support/webmasters/bin/answer.py?answer=34481
I want the w's always, how do I do it?
areidmtm
08-08-2006, 08:28 AM
Add this line to your .htaccess file. If you do not know what or have an .htaccess file, you can create one if there isn't already one in your public_html directory. You can create one with any text editor, just make sure it is named exactly, .htaccess not .txt
Then add this line:
RewriteEngine on
#Only add the following line if this is an addon domain
#RewriteCond %{HTTP_HOST} ^(www\.)?addon.yourdomain.com$ [OR]
RewriteCond %{HTTP_HOST} ^yourdomain.com$
RewriteRule ^(.*)$ http://www.yourdomain.com [R=301,L]
This will make it always show the 'www.' in the URL
vegasgwm
08-08-2006, 12:18 PM
just curious, why do you want only www?
areidmtm
08-08-2006, 12:58 PM
Google and other spiders get confused when you use both with and without the www. Some people will argue which it better, personally I use it with the www. It really doesn't matter, just how you'd like it too look. I think that there needs to be a set standard. With or without, I dont care, I just think it should be set as a standard.
vegasgwm
08-08-2006, 03:49 PM
I've seen instances where i typed somesite.com and could not reach the site while www.somesite.com did. Anybody knows why? I never understood it.
areidmtm
08-08-2006, 04:28 PM
it just depends on how the DNS entry is set up.
xe-cute
08-12-2006, 09:10 AM
In my htaccess file i have:
Options +FollowSymLinks
RewriteEngine On
RewriteCond %{HTTP_HOST} !^www\.mysite\.net [NC]
RewriteRule ^(.*)$ http://www.mysite.net/$1 [R=301,L]
This is what i used at my old host with no problem.
However over at bluehost for some reason i get the following MAIN error in error log:
[Sat Aug 12 09:13:26 2006] [error] [client 66.249.72.105] mod_rewrite: maximum number of internal redirects reached. Assuming configuration error. Use 'RewriteOptions MaxRedirects' to increase the limit if neccessary.
If I use the MaxRedirects=10 code than it just gives me even more problems, also i am not too sure if that is the solution as people should only be redirected once and only if they try to use the none 'www' link.
Anyone got any clues as to why this is happening?
thenewguy
08-24-2006, 09:12 AM
I added the text below (with my domain name in place of example.com) to the empty .htaccess file in my public_html folder.
RewriteEngine on
RewriteCond %{HTTP_HOST} ^example.com$
RewriteRule ^(.*)$ http://www.example.com [R=301,L]
It worked, but now my WordPress blog with no posts yet that I installed with Fantastico is messed up (no colors, no formatting, text only except for the search box and button).
Basil
08-25-2006, 12:03 AM
RewriteEngine On
RewriteCond %{HTTP_HOST} ^www\.example\.com$ [NC]
RewriteRule ^(.*)$ http://example.com/$1 [R=301,L]
This is what I use to get rid of the www. It's redundant, why keep it?
I added the text below (with my domain name in place of example.com) to the empty .htaccess file in my public_html folder.
RewriteEngine on
RewriteCond %{HTTP_HOST} ^example.com$
RewriteRule ^(.*)$ http://www.example.com [R=301,L]
It worked, but now my WordPress blog with no posts yet that I installed with Fantastico is messed up (no colors, no formatting, text only except for the search box and button).
To fix things, should I delete all of the files in my hosting account (or just uninstall WordPress somehow (using Fantastico?) ), then create a new public_html folder, then create a new .htaccess file with the text in it, and then install WordPress via Fantastico?
Just drop the htaccess file unless you really really want to force people to have www in the address bar.
dkinzer
08-25-2006, 09:14 AM
[code]This is what I use to get rid of the www. It's redundant, why keep it? Just drop the htaccess file unless you really really want to force people to have www in the address bar.
The important points are 1) to allow access to your site with or without the www prefix and 2) to ensure that search engines are properly redirected to the form you've chosen so that they don't see two different URLs with identical content.
As to which form you choose, it probably doesn't make much difference. However, it should be noted that if you might choose to get a dedicated IP in the future and would plan to purchase an SSL certificate through BlueHost, only the www-prefixed form of the secure URL is supported. I don't know the details of why this is the case but I've been assured that this is so by a L3 BlueHost tech. If you are otherwise undecided, this fact may push you to adopt the www-prefixed URL as your official standard.
To reiterate, regardless of which form you choose your human users probably won't notice the difference.
Basil
08-26-2006, 11:24 PM
That was a rhetorical question, all that www represents right now is deprecated. It used to actually mean something, however it has since lost it's usefulness and will eventually be phased out completely. It literally serves NO function other than invalidating that as a subdomain.
LouDog
08-28-2006, 09:16 PM
I'm having a problem using the code above for the .htaccess and still being able to publish w/FrontPage, anyone have a solution?
I tried adding this the .htaccess in the public_html folder, and it works good, except I cannot publish with FP anymore... It returns the following:
403 Permission Denied
403 Permission Denied You do not have permission for this request /_vti_bin/_vti_aut/author.exe
Is there a fix for this?
This is my .htaccess file as it is right now:
# -FrontPage-
IndexIgnore .htaccess */.??* *~ *# */HEADER* */README* */_vti*
<Limit GET POST>
order deny,allow
deny from all
allow from all
</Limit>
<Limit PUT DELETE>
order deny,allow
deny from all
</Limit>
AuthName www.luirette.com
AuthUserFile /home/luirette/public_html/_vti_pvt/service.pwd
AuthGroupFile /home/luirette/public_html/_vti_pvt/service.grp
RewriteEngine on
RewriteCond %{HTTP_HOST} ^luirette.com$
RewriteRule ^(.*)$ http://www.luirette.com [R=301,L]
Anyone? Advice? Tips? Insults? Hysterical Laughter?
thenewguy
08-28-2006, 10:58 PM
Although using .htaccess on your server is extremely unlikely to cause you any problems (if something is wrong it simply won't work), you should be wary if you are using the Microsoft FrontPage Extensions. The quote is from
http://helpdesk.bluehost.com/kb/index.php?x=&mod_id=2&id=130
LouDog
08-29-2006, 06:32 PM
Awwww, man!! That F'n blows! I just moved to BH just to get proper 301-redirects, and I can't use it?!
Warning
Before beginning using .htaccess, I should give you one warning. Although using .htaccess on your server is extremely unlikely to cause you any problems (if something is wrong it simply won't work), you should be wary if you are using the Microsoft FrontPage Extensions. The FrontPage extensions use the .htaccess file so you should not really edit it to add your own information. If you do want to (this is not recommended, but possible) you should download the .htaccess file from your server first (if it exists) and then add your code to the beginning.
Well, I tried putting the redirect first, no luck. Any other advice out there other than being "wary"? Maybe a workaround besides it's "not recommended"? I really don't want to cancel another host and try again, this is getting rediculous. :confused:
Basil
08-29-2006, 06:39 PM
What are you talking about, it works fine..
If you're referring to FrontPage, well, don't use it. FrontPage sucks.
Okay good news I didn't actually read any of your previous posts, but what your code SHOULD say isRewriteEngine on
RewriteCond %{HTTP_HOST} ^luirette\.com$
RewriteRule ^(.*)$ http://www.luirette.com/$1 [R=301,L] mmkay?
thenewguy
08-29-2006, 07:33 PM
I deleted the text from my .htaccess file and my WordPress blog got back to normal (but my forced www display stopped working, of course).
Then I used Fantastico to uninstall WordPress
Then I added the text to my empty .htaccess file (and the w's showed)
Then I installed WordPress using Fantastico and my WordPress blog was messed up again.
I am still looking for a solution. I would like to use BlueHost to host a WordPress blog that always displays the www. BlueHost is one of the five web hosts that WordPress specifically recommends.
Basil
08-29-2006, 10:30 PM
RewriteEngine On
RewriteCond %{HTTP_HOST} ^mysite\.biz$
RewriteRule ^(.*)$ http://www.mysite.biz/$1 [R=301,L]
Use that in the .htaccess file in your public_html folder, not the wordpress folder, and you shouldn't be having any problems.
LouDog
08-30-2006, 06:40 PM
What are you talking about, it works fine..
If you're referring to FrontPage, well, don't use it. FrontPage sucks.
What are you talking about, FrontPage won't publish to it!
BTW, "frontpage sucks" doesn't help anything here. I asked for help, not a critique.
I hate FP as much as you, but it's not me using it... it's the end-user. You can post your trash talk in mySpace like everyone else, thanks.
Basil
08-30-2006, 07:25 PM
Okay first off, I did try to help you, secondly you did ask for critique, and thirdly FrontPage sucks.
LouDog
08-30-2006, 08:00 PM
I obviously didn't need a review of FP. I'm stuck with it, fine, let it go!
Next time actually READ the thread before replying, then reply if you feel like being helpful, not sarcastic.
Okay good news I didn't actually read any of your previous posts, but what your code SHOULD say is
Whatever dude.
Basil
08-30-2006, 08:24 PM
Again, I'm assuming you didn't look at what I suggested, since you haven't said whether it worked or not.
thenewguy
08-31-2006, 12:54 AM
Of the possible solutions that have been suggested in this thread or I have found on other webpages, I am not sure which one to pick without doing more hours of research and experimentation.
RewriteEngine on
RewriteCond %{HTTP_HOST} ^example.com$
RewriteRule ^(.*)$ http://www.example.com [R=301,L]
RewriteEngine On
RewriteCond %{HTTP_HOST} ^example\.com$
RewriteRule ^(.*)$ http://www.example.com/$1 [R=301,L]
RewriteEngine On
RewriteCond %{HTTP_HOST} !^www\.example\.com$ [NC]
RewriteRule ^(.*) http://www.example.com/$1 [L,R]
RewriteEngine on
RewriteCond %{HTTP_HOST} ^example.com$
RewriteRule (.*) http://www.example.com/$1 [R=Permanent]
Any .htaccess experts here?
Basil
08-31-2006, 01:08 AM
RewriteEngine on
RewriteCond %{HTTP_HOST} ^example.com$
RewriteRule ^(.*)$ http://www.example.com [R=301,L]
This doesn't work right. It redirects http://example.com/anything to http://www.example.com. Typing www.example.com/something works.
RewriteEngine On
RewriteCond %{HTTP_HOST} ^example\.com$
RewriteRule ^(.*)$ http://www.example.com/$1 [R=301,L]
This looks fine, it's a 301 redirect (search engine friendly) from example.com/something to http://www.example.com/something.
RewriteEngine On
RewriteCond %{HTTP_HOST} !^www\.example\.com$ [NC]
RewriteRule ^(.*) http://www.example.com/$1 [L,R]
This redirects anything that isn't www.example.com to www.example.com, so if you want to keep subdomains in the adress bar.. don't use this. sub.domain.com will go to domain.com/sub
RewriteEngine on
RewriteCond %{HTTP_HOST} ^example.com$
RewriteRule (.*) http://www.example.com/$1 [R=Permanent]
This is basically the same as an earlier one. Works fine.
LouDog
08-31-2006, 05:54 PM
The redirect works great, but FP gives me this error when publishing:
403 Permission Denied
403 Permission Denied You do not have permission for this request /_vti_bin/shtml.exe/_vti_rpc
Any solutions for this?
LouDog
08-31-2006, 06:31 PM
For anyone that cares besides me, here's a note that should also be in the knowledgebase!
If using FrontPage with an .htaccess redirect, use the previously given code and use this too:
Options +FollowSymLinks
in here:
Your public html .htaccess
_vti_bin/.htaccess (replace Options none)
_vti_bin/_vti_adm/.htaccess (replace Options none)
_vti_bin/_vti_aut/.htaccess (replace Options none)
Redirect now works, publishing works, and yes, Basil; FP still sucks.;)
thenewguy
09-01-2006, 06:28 PM
I found this older discussion about this topic
http://www.bluehostforum.com/showthread.php?t=1019
and got a private message suggesting that I use
RewriteEngine On
RewriteCond %{HTTP_HOST} ^example\.com$
RewriteRule ^(.*)$ http://www.example.com/$1 [R=301,L]
but I think that if BlueHost is using Apache 1.3.37 then customers should use
RewriteCond %{HTTP_HOST} !^example\.com [NC]
RewriteCond %{HTTP_HOST} !^$
RewriteRule ^/(.*) http://www.example.com/$1 [L,R]
because that style of code is on here
http://httpd.apache.org/docs/1.3/misc/rewriteguide.html
If that is the best code to use, it could be put into the Support Center's Knowledgebase.
Basil
09-01-2006, 07:29 PM
RewriteCond %{HTTP_HOST} !^example\.com [NC]
RewriteCond %{HTTP_HOST} !^$
RewriteRule ^/(.*) http://www.example.com/$1 [L,R]
Just so you know that doesn't do anything.
thenewguy
09-01-2006, 10:57 PM
I translated it from # For sites running on a port other than 80
RewriteCond %{HTTP_HOST} !^fully\.qualified\.domain\.name [NC]
RewriteCond %{HTTP_HOST} !^$
RewriteCond %{SERVER_PORT} !^80$
RewriteRule ^/(.*) http://fully.qualified.domain.name:%{SERVER_PORT}/$1 [L,R]
# And for a site running on port 80
RewriteCond %{HTTP_HOST} !^fully\.qualified\.domain\.name [NC]
RewriteCond %{HTTP_HOST} !^$
RewriteRule ^/(.*) http://fully.qualified.domain.name/$1 [L,R]I thought that apache.org would be the best place to look for a definitive answer. I think it would be good for all BlueHost customers to use the best code.
Basil
09-02-2006, 11:40 AM
Right, but their code is to get rid of the www. (which I prefer)
thenewguy
09-03-2006, 01:09 AM
Many of the large Internet companies use the w's.
Does anyone have any experience with the VirtualHost code?
http://httpd.apache.org/docs/1.3/misc/FAQ.html#canonical-hostnames
vBulletin® v3.7.4, Copyright ©2000-2009, Jelsoft Enterprises Ltd.