Take the 2-minute tour ×
Webmasters Stack Exchange is a question and answer site for pro webmasters. It's 100% free, no registration required.

On my site, say example.com, if I try to access test.example.com, Firefox automatically adds www. to test.example.com, making it www.test.example.com, which causes an error. However, if I visit a site like my.ebay.com, no www. is added so no error occurs. What's going on?

Just in case, my .htaccess file is as follows:

Options -Multiviews
RewriteEngine On
RewriteCond %{HTTP_HOST} ^example.com
RewriteRule ^(.*)$ http://www.example.com/$1 [R=301,L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ $1.php

I looked through Firebug and it seems like Firefox doesn't even make an attempt to reach test.example.com before reverting to www.test.example.com.

One nuance I didn't realize until now. If I try to access the site using test.example.com/, the www. is added. If however that trailing slash is not there, then I am sent to the sub domain properly.

share|improve this question

migrated from stackoverflow.com Jun 30 '12 at 21:35

This question came from our site for professional and enthusiast programmers.

    
What error do you get? –  sandradev Jun 30 '12 at 16:17
    
Try pinging the address and see that it actually exists in DNS. Some browsers second guess if test.example.com does not resolve and try adding www for a second attempt. –  Joachim Isaksson Jun 30 '12 at 16:21
    
I tried pinging the subdomain and I am able to reach it. As for the error I get, it reads "You tried to visit www.test.example.com, which is not loading." –  user532493 Jun 30 '12 at 16:44
    
possible duplicate of Yet Another Mod_Rewrite Issue - Firefox Adds www –  mario Jun 30 '12 at 20:54
add comment

3 Answers 3

Have you tried to manually adding the protocol prefix?

http://test.example.com won't get redirected.

Options -Multiviews
RewriteEngine On
RewriteCond %{HTTP_HOST} ^www(.*)
RewriteCond %{HTTP_HOST} !^www.example.com
RewriteRule ^(.*).example.com/(.*)$ http://$1.example.com/$2 [R=301,L]

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

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ $1.php

In the future, look at this article: http://support.mozilla.org/en-US/questions/714016

share|improve this answer
    
But I'm trying to build a website for others and I don't want them to have to go through that. I just want my site to be like the other millions out there. –  user532493 Jun 30 '12 at 16:31
    
Try the updated htaccess –  sixeightzero Jun 30 '12 at 16:33
    
That fix would only work for one subdomain, I need it to work for all subdomains. –  user532493 Jun 30 '12 at 16:43
    
Actually, the updated .htaccess doesn't seem to fix it for any subdomains. –  user532493 Jun 30 '12 at 16:53
    
The issue still exists even with that updated .htaccess. –  user532493 Jun 30 '12 at 17:09
add comment

There's www automatically added in your url because you stated it in your htaccess rule.

Look at this part:

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

That mean to add www to your url when its not present.

share|improve this answer
    
This only matters if the ul just starts with example.com. test.example.com would not match tht rule –  sixeightzero Jun 30 '12 at 16:35
    
Yeah, if I remove the two lines you quoted from my .htaccess file I still get the error. –  user532493 Jun 30 '12 at 16:38
add comment

It looks like it was a small glitch or something that was fixed by clearing the browser's history.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.