我有(例如)网站help.test.pl
我想从子网站help.test.pl/site1
重定向到此网站的另一个网址:help.test.pl/site1/info/sport
如果我在apache中做:
Redirect 301 /site1 https://help.test.pl/site1/info/sport
如果我在浏览器中运行网站help.test.pl/site1
,那么" info/sport/
" URL的循环。
网址如下:
https://help.test.pl/site1/info/sport/info/sport/info/sport/info/sport/info/sport/info/sport/info/sport/info/sport/info/sport/info/sport/info/sport/info/sport/info/sport/info/sport/info/sport/info/sport
我做错了什么?
答案 0 :(得分:1)
您可以使用以下一种方法:
1)使用RewriteRule
。
RewriteEngine on
RewriteBase /
RewriteCond %{REQUEST_URI} /site1$
RewriteRule ^/?(.*)$ https://help.test.pl/site1/info/sport [R=301,L]
2)使用RedirectMatch
RedirectMatch 301 /site1$ https://help.test.pl/site1/info/sport
编辑:添加另一页。
RewriteEngine on
RewriteBase /
RewriteCond %{REQUEST_URI} /site1$ [OR]
RewriteCond %{REQUEST_URI} /site2$
RewriteRule ^/?(.*)$ https://help.test.pl/$1/info/sport [R=301,L]