开发者

Need help figuring out .htaccess rules

I'm pretty new to apache, and I need some help with som开发者_运维知识库e .htaccess rewrite rules. Here're the current rules:

RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_URI} !/beta/index\.php$
RewriteRule ^(.*)$ /beta/index\.php [R=302,L] 

Basically it redirects any requests to mydomain.com\beta\index.php, except if a filename's specified. This works fine for now.

Here's the problem:

I have a subdomain beta.mydomain.com which I don't want these rules to apply to. Any URL on beta.subdomain.com should be treated normally. However, since the .htaccess is at the server root, it's rules are messing with the beta.subdomain.com as well.

I've tried many different combinations of regex, but I can't figure it out. Help!


You need use something like this (to check if your request was related to specific domain/subdomain):

RewriteCond %{HTTP_HOST} ^([^.]+)\.mydomain\.com(:80)?$ 

20 seconds were missed... But my answer is better ;)


RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_URI} !/beta/index\.php$
RewriteCond %{HTTP_HOST} !^beta\.subdomain\.com 
RewriteRule ^(.*)$ /beta/index\.php [R=302,L]  

This ought to do the trick!

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜