.htaccess if指令

时间:2012-03-29 19:34:46

标签: .htaccess

在.htaccess我有这样的事情:

RewriteCond %{REQUEST_URI} (\/out\/pictures\/)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule (\.jpg|\.gif|\.png)$ core/utils/getimg.php

我想将其更改为

RewriteCond %{REQUEST_URI} (\/out\/pictures\/)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
if url == www.mysite.com {
  RewriteRule (\.jpg|\.gif|\.png)$ core/utils/getimg.php
} else {
  RewriteRule (\.jpg|\.gif|\.png)$ core/utils/getimg1.php
}

有可能以某种方式吗?

1 个答案:

答案 0 :(得分:1)

不幸的是,我认为有必要将其分为两部分:

RewriteCond %{REQUEST_URI} (\/out\/pictures\/)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{HTTP_HOST} ^www\.mysite\.com
RewriteRule (\.jpg|\.gif|\.png)$ core/utils/getimg.php

RewriteCond %{REQUEST_URI} (\/out\/pictures\/)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{HTTP_HOST} !^www\.mysite\.com
RewriteRule (\.jpg|\.gif|\.png)$ core/utils/getimg1.php

我没有测试过这个 - 所以你的里程可能会有所不同!