Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/url/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
.htaccess 如何在htaccess中重定向url,很少有例外_.htaccess_Url_Redirect - Fatal编程技术网

.htaccess 如何在htaccess中重定向url,很少有例外

.htaccess 如何在htaccess中重定向url,很少有例外,.htaccess,url,redirect,.htaccess,Url,Redirect,我想重定向我的旧网站的所有网址到新的,除了少数链接。如何使用htaccess实现这一点 除了这些链接 a) http://localhost/track/click_thru.asp b) http://localhost/track/view_tracker.asp c) http://localhost/track/pass_thru.asp 网站上的所有其他链接都应重定向到我的新网站。尝试将这些规则添加到旧网站文档根目录中的htaccess文件中: RewriteEngine On

我想重定向我的旧网站的所有网址到新的,除了少数链接。如何使用htaccess实现这一点

除了这些链接

a) http://localhost/track/click_thru.asp

b) http://localhost/track/view_tracker.asp

c) http://localhost/track/pass_thru.asp

网站上的所有其他链接都应重定向到我的新网站。

尝试将这些规则添加到旧网站文档根目录中的htaccess文件中:

RewriteEngine On
RewriteCond $1 !^track/(click_thru|view_tracker|pass_thru)\.asp
RewriteRule ^(.*)$ http://www.example.com/$1 [L,R=301]

www.example.com
是您的新站点。如果您不希望重定向中包含路径,可以从规则末尾删除
$1
(例如,转到旧站点上的
/blah
重定向到
http://www.exmaple.com/blah
)。

您使用的是apache还是IIS?@JonLin我使用的是apache