Reputation: 269
I tried to set up an htaccess file, which simply redirects all urls which are unlike one to another url:
RewriteCond %{HTTP_HOST} !^www.example.com[NC]
RewriteRule ^(.*)$ http://www.example.com/$1 [R=301,L]
But i recognized something strange, for some reason it results in an endless loop. So i did some tests.
My Webspace looks like this:
-root
---folder 1
---folder 2
And i have 2 Domains, one is targeting the root-folder and the other one is targeting a subfolder:
-root <--- http://another-url.com
--- folder 1
--- folder 2 <---- http://www.example.com
I asume that %{HTTP_HOST}
from my htaccess file is recognizing every url as the http://another-url.de, which is unlike my www.example.com and so it redirects to www.example.com which of cause results in an endless loop.
I did a simple check: I created a PHP File in my folder 2 which prints the $_SERVER[HTTP_HOST]
. Opend the file through http://www.example.com and i got the output www.another-url.com.
Does anyone know whats going on? And how i could solve this?!
Upvotes: 2
Views: 1227
Reputation: 1831
I know this is an old question, but I had the same issue today in Google Chrome, on a local environment that hosts many fake development domains. Here's what fixed it for me:
Empty Cache and Hard Reload
After that, the correct domain loaded. So Chrome must have had a bad DNS entry cached or something.
Upvotes: 0