开发者

mod_rewrite expression for subfolders?

I have wildcard subdomains turned on and this rewrite in my root directory to catch the subdomain and folder:

RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} !www.mysite.com$ [NC]
RewriteCond %{HTTP_HOST} ^(www\.)?([^.]+)\.mysite\.com$ [NC]
RewriteRule ^(.*)$ process.php?id=%2
RewriteRule ^([^/.]+)/?$ process.php?id=%2/$1 [L]

the second-last line is supposed to just take us to process.php?id=subdomain if there is no subfolder requested. The last line is supposed to take us to process.php?id=subdomain/subfolder/ if there is indeed a subfolder requested (as in subdomain.mysite.com/subfolder/).

开发者_StackOverflow社区Each of these works on its own, but together they don't work. I just want it to use the first one if there is no subfolder specified, or the last one if there is. I suspect they need to be combined with regex but I'm in the dark as to how to express this?


Swap the order of the last 2 lines. The 2nd to last line might be getting greedy and matching both cases...

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜