我已经为我的网站创建了301重定向代码。下面是我所有类别的代码,以重定向到新的url
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
让我知道我的代码是否正确?
谢谢
发布于 2012-08-23 14:23:04
这是不正确的。%{HTTP_HOST}只是请求的Host:头中提供的主机。它不会包含任何路径信息。你可以把这种情况分成两件事:
RewriteCond %{HTTP_HOST} ^testsite.com$ [NC]
RewriteRule ^/?categories/city/(.*)$ /$1 [R=301,L,NC]https://stackoverflow.com/questions/12085640
复制相似问题