开发者

htaccess rewrite rule to allow local development

开发者 https://www.devze.com 2023-04-04 12:12 出处:网络
I\'m using a .htaccess file to force all \'example.com\' requests to \'www.example.com\' The problem is, now I\'d like to develop my website locally on my machine, and I\'m using a custom host define

I'm using a .htaccess file to force all 'example.com' requests to 'www.example.com'

The problem is, now I'd like to develop my website locally on my machine, and I'm using a custom host defined as example.local -- that points to my version of the website on my local MAMP stack.

#force non-www to www.example.com
    R开发者_如何学JAVAewriteCond %{HTTP_HOST} !^www.example.com$
    RewriteRule ^(.*)$ http://www.example.com/$1 [R=301]

How can i modify this htaccess file to not push my example.local requests to www.example.com?


Add a second condition to your rewrite rule

#force non-www to www.example.com
RewriteCond %{HTTP_HOST} !^www.example.com$
RewriteCond %{HTTP_HOST} !^example.local$
RewriteRule ^(.*)$ http://www.example.com/$1 [R=301]
0

精彩评论

暂无评论...
验证码 换一张
取 消