【发布时间】:2014-10-05 07:03:26
【问题描述】:
我还有一个关于 mod_rewrite 的问题。如果用户想要图像(uri 末尾的.png、.jpe?g、.gif)然后重定向到 index1.html,否则重定向到 index2.html。测试人员 (http://htaccess.madewithlove.be/) 与没有 .png,jpe?g,.gif 的 uri 不匹配,因为在正确的范围内,但我的 localhost 匹配,这就是问题所在。
正确的例子: 输入:
localhost/image.png
输出
localhost/index1.html
输入:
localhost/image
输出
localhost/index2.html
但我的本地主机真正做了什么: 输入:
localhost/image.png
输出
localhost/index2.html
输入:
localhost/image
输出
localhost/index2.html
我的 htaccess:
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_URI} !^(.*)(.png|.jpe?g|.gif)$
RewriteRule ^(.*)$ index2.html
RewriteCond %{REQUEST_URI} ^(.*)(.png|.jpe?g|.gif)$
RewriteRule ^(.*)$ index1.html
你能帮忙吗?谢谢。
【问题讨论】:
标签: php regex apache .htaccess mod-rewrite