.htaccess if指令

.htaccess if指令,.htaccess,.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\/) R

在.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
}

有可能吗?

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

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

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

最棒的东西-很高兴它成功了。你介意接受这个答案吗?魔法,谢谢(我今晚好像在玩声誉游戏!)