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

2023-09-02 20:34:41 作者:幼儿园大佬

我有一个的index.php在我的主域根

I have a index.php in my main domain root

domain.com/index.php

domain.com/index.php

和香港专业教育学院搬到我的论坛这是在同一个根到一个子域

And ive moved my forums which was in the same "root" to a subdomain

forums.domain.com

forums.domain.com

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

I need to Redirect everything except the index.php

香港专业教育学院tryed的方式加载并没有似乎工作

ive tryed loads of ways and none seem to work

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]

如果任何人有任何想法,将是巨大的 作为上述codeS我想他们在Google上搜寻有关。 干杯

If anyone has any ideas that would be great as for the above codes I would them googling about. Cheers

推荐答案

您可以使用,而不是重写RedirectMatch,就是代替你都显示了所有重写块:

You may use RedirectMatch instead of rewriting, that is, replace all the rewrite block you are showing with:

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

您可以看到正则表达式对Regexr 这里的完整解释。简言之,它发出的所有URI的不可以开头的index.php 来forums.domain.com。

You can see the full explanation of the regex on Regexr here. In brief, it sends all the URIs NOT beginning with /index.php to forums.domain.com.

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

If you don't need any other rewrite rule, you can turn off rewriting by removing all the lines beginning with "Rewrite" from your .htaccess.