Forum Moderators: phranque
Whenever I browse to [localhost...] I end up at http://www.example.com/ where www.example.com is the url of the live website. I must have set something up incorrectly in the .htaccess file or may be have Apache set up incorrectly locally.
Anybody have any ideas as to what setting could cause this?
Cheers John
In the .htaccess file I have a line
RewriteCond %{HTTP_HOST}!^www\.example\.com
Would that be redirecting localhost to the live server?
That line says, "If requested host is NOT www.example.com" and the most likely following rule would say, "then redirect to www.example.com."
In order to avoid having two versions of the code, one for testing and one for use on the live site, you can simply 'allow' the use of localhost without redirecting. Something like:
RewriteCond %{HTTP_HOST} !^www\.example\.com
RewriteCond %{HTTP_HOST} !^localhost
RewriteCond %{HTTP_HOST} !^127\.0\.0\.1
RewriteRule (.*) http://www.example.com/$1 [R=301,L]
Jim