尝试在一个.htaccess中处理多个潜在的重写
每个子域都应该解析为一个文件夹 每个/ a /用户名应解析为/?a =用户名
我有各自的规则。但我无法弄清楚如何让它们同时工作。
示例(现在工作):
我需要做些什么:
RewriteEngine on
RewriteRule ^index\.php?$ / [NC,R,L]
#RewriteRule ^(.*).domain.com$ http://www.domain.com/$1 [QSA,R=302,L]
RewriteCond "%{HTTP_HOST}" !^www.* [NC]
RewriteCond "%{HTTP_HOST}" !^admin.* [NC]
RewriteCond "%{HTTP_HOST}" !^mail.* [NC]
RewriteCond "%{HTTP_HOST}" !^email.* [NC]
RewriteCond "%{HTTP_HOST}" ^([^\.]+).domain.*$
RewriteRule ^(.*)$ http://www.domain.com/%1 [R=302]
RewriteRule ^a/(.*)$ http://www.domain.com/%1?a=$1 [R=302,L]
答案 0 :(得分:1)
尝试将规则更改为:
RewriteEngine on
RewriteRule ^index\.php?$ / [NC,R,L]
#RewriteRule ^(.*).domain.com$ http://www.domain.com/$1 [QSA,R=302,L]
RewriteCond "%{HTTP_HOST}" !^www.* [NC]
RewriteCond "%{HTTP_HOST}" !^admin.* [NC]
RewriteCond "%{HTTP_HOST}" !^mail.* [NC]
RewriteCond "%{HTTP_HOST}" !^email.* [NC]
RewriteCond "%{HTTP_HOST}" ^([^\.]+).domain.*$
RewriteRule ^$ http://www.domain.com/%1 [R=302]
RewriteCond "%{HTTP_HOST}" !^www.* [NC]
RewriteCond "%{HTTP_HOST}" !^admin.* [NC]
RewriteCond "%{HTTP_HOST}" !^mail.* [NC]
RewriteCond "%{HTTP_HOST}" !^email.* [NC]
RewriteCond "%{HTTP_HOST}" ^([^\.]+).domain.*$
RewriteRule ^a/(.*)$ http://www.domain.com/%1?a=$1 [R=302,L]