重定向的所有页面,除了一个页面到子域名的htaccess

问题描述:

我在我的主域名根的index.php重定向的所有页面,除了一个页面到子域名的htaccess

domain.com/index.php

并且Ive动了我的论坛,这是在同“根”的子域

forums.domain.com

我需要重定向以外的所有的index.php

香港专业教育学院tryed的方式和无负载似乎工作

Options +FollowSymLinks 
RewriteEngine On 
RewriteBase/
RewriteCond %{SCRIPT_FILENAME} !index\.php$ 
RewriteRule ^(.*)$ http://forums.domain.com [L,R] 

RewriteEngine On 
RewriteCond %{HTTP_HOST} animelon\.com [NC] 
RewriteCond %{REQUEST_URI} !^index\.php$ 
RewriteRule ^(.*)$ http://forums.domain.com/$1 [R=301,L] 

如果任何人有这将是巨大 作为上面的代码我想他们对谷歌搜索任何想法。 干杯

您可以使用RedirectMatch的不是重写,就是取代所有您与显示改写模块:

RedirectMatch ^(/(?!index\.php).*) http://forums.domain.com$1 

你可以看到Regexr here正则表达式的完整解释。简而言之,它将所有从/index.php开始的URI NOT发送到forums.domain.com。

如果您不需要任何其他重写规则,可以通过从.htaccess中删除以“重写”开头的所有行来关闭重写。

+0

嗨,那么只需使用RewriteEngine RedirectMatch ^(/(?! index \ .php)。*)http://forums.animelon.com$1就是这样吗?对不起,这种事情不太好......我尝试了以上,但它没有工作,谢谢 – VK27 2011-06-13 12:49:38

+0

尝试关闭RewriteEngine(即,'RewriteEngine off'),如果它仍然无法正常工作,请尝试更改第二个指令是'RedirectMatch /(?!index.php)(.+)http:// forums.domain.com/$ 1' – 2011-06-13 13:02:58

+0

同一个伴侣仍然会将所有内容重定向到forums.animelon.com – VK27 2011-06-13 13:10:32