【发布时间】:2014-09-06 05:52:54
【问题描述】:
我在html中添加了一些绝对路径,即GET请求到其他域。
<script src="http://www.example.com/dir/file.js"></script>
<script src="http://www.sample.com/js/script.js"></script>
<link rel="stylesheet" type="text/css" href="http://www.example.com/all/home/style.css" />
<link rel="stylesheet" type="text/css" href="mystyle.css" />
如何将所有对 example.com 的请求重定向到 localhost, 127 0 0 1 那是 http://www.example.com/ 应该被重定向到 localhost/
不应影响其他请求
以下代码适用于重定向以 dir/ 开头的路径,但当我使用绝对域名 http://www.example.com/ 而不是 dir 链接文件时不起作用
RewriteRule ^dir/(.*)$ http://localhost/dev/$1 [R=301,L]
RewriteCond %{REQUEST_FILENAME} !/http://localhost/dev/.*
如何使用 htaccess 做到这一点?
【问题讨论】:
标签: apache .htaccess redirect localhost absolute-path