mod_rewrite只重定向索引页面

时间:2013-08-20 11:01:29

标签: regex apache .htaccess redirect mod-rewrite

问题是遵循.htaccess语法:

Options +FollowSymLinks
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} robots.txt$ [NC]
RewriteRule ^([^/]+) $1 [L]

RewriteCond %{HTTP_HOST} ^bd-spb\.ru$ [NC]
RewriteRule ^(.*)$ http://xn----8sbbkdenhe5aqs7a.xn--p1ai/$1 [R=301,L]
RewriteCond %{HTTP_HOST} ^www.bd-spb\.ru$ [NC]
RewriteRule ^(.*)$ http://xn----8sbbkdenhe5aqs7a.xn--p1ai/$1 [R=301,L]

仅重定向索引页面。因此,如果我转到bd-spb.ru,我会得到бизнес-диалог.рф,但如果我举例here,则不会重定向我here

如何实现这一目标?

1 个答案:

答案 0 :(得分:1)

好用这个替换你的代码:

Options +FollowSymLinks
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} robots\.txt$ [NC]
RewriteRule ^([^/]+) $1 [L]

RewriteCond %{HTTP_HOST} ^(www\.)?bd-spb\.ru$ [NC]
RewriteRule ^(.*)$ http://xn----8sbbkdenhe5aqs7a.xn--p1ai/$1 [R=301,L,B]
相关问题