【发布时间】:2017-03-12 21:44:57
【问题描述】:
我已经为 wamp 下载并配置了一个在线托管网站。发生的唯一问题是,如果我点击本地网站上的任何链接,我将被重定向到我的在线网站。
不幸的是,我无法设置我的 htaccess,以便它更改本地服务器的在线链接。
例如:
在重定向到www.example.com/blog 的站点上的链接应重写为重定向到example.dev/blog。
为此,我尝试过类似的方法:
RewriteEngine on
RewriteCond %{HTTP_HOST} ^(www\.)?example\.com(.*) [NC]
RewriteRule ^(.*)$ example.dev/$1 [R=301,L]
但它不起作用。
编辑: 一个更深入的例子:
我有一个网站,地址是:www.example.com,它的本地 wamp 地址是 example.dev。现在我在本地example.dev 根目录的index.html 中有一个链接<a href="http://www.example.com/shop.html">Shop</a>。现在我需要一种将http://www.example.com/shop.html 重定向到http://example.dev/shop.html 的方法。这应该适用于所有子页面,不仅适用于商店。也适用于样式表等。
【问题讨论】:
标签: php apache .htaccess redirect