0

我为我的网站创建了 301 重定向代码。以下是我所有类别的代码以重定向到新网址

Options +FollowSymlinks
RewriteEngine on
rewritecond %{http_host} ^testsite.com/categories/city/$1 [nc]
rewriterule ^(.*)$ http://www.testsite.com/$1 [r=301,nc]

我想将http://www.testsite.com/categories/city/pune重定向到http://www.testsite.com/Pune

让我知道我的代码是否正确?

谢谢

4

1 回答 1

0

这是不正确的。是请求标头中提供的%{HTTP_HOST}唯一主机Host:。它不会包含任何路径信息。您可以将该条件分为两件事:

RewriteCond %{HTTP_HOST} ^testsite.com$ [NC]
RewriteRule ^/?categories/city/(.*)$ /$1 [R=301,L,NC]
于 2012-08-23T06:23:03.527 回答