0

我有一个域test.com和一个子域sub.test.com

现在,我需要将 URL 重写sub.test.comtest.com/?state=sub,并且 URL 类似于 sub.test.com/content/totest.com/content/?state=subsub.test.com/content/proceed/to test.com/content/proceed/?state=sub

第一个 URL 的规则有效,如下所示:

RewriteCond %{HTTP_HOST} !^www\.test\.com
RewriteCond %{HTTP_HOST} !^webmail\.test\.com
RewriteCond %{HTTP_HOST} !^m\.test\.com
RewriteCond %{HTTP_HOST} ([^.]+)\.test\.com
RewriteCond %{REQUEST_URI} !^/index\.php$
RewriteCond %{REQUEST_URI} !robots.txt.*
RewriteRule  ^$ http://www.test.com/?state=%1 [P]

知道怎么做吗?

4

1 回答 1

0

这条规则应该适合你:

RewriteCond %{HTTP_HOST} !^(?:www|webmail|m)\.test\.com$ [NC]
RewriteCond %{HTTP_HOST} ([^.]+)\.test\.com$ [NC]
RewriteCond %{REQUEST_URI} !^/(index\.php|robots\.txt) [NC]
RewriteRule ^ http://www.test.com%{REQUEST_URI}/?state=%1 [P]
于 2013-11-04T15:30:44.610 回答