0
我试图设置一个.htaccess文件,该文件将每个请求URL作为GET
传递到名为index.php
的文件中。唯一的例外是请求URL指向目录res。现有文件夹的mod_rewrite条件
实例:
/wiki/cool-stuff => index.php?uri=/wiki/cool-stuff
/wiki/cool-stuff?news=on => index.php?uri=/wiki/cool-stuff&news=on
/res/cool-photo.jpg => res/cool-photo.jpg
两个问题:
- 在第二示例中传递给
/wiki/cool-stuff
的GET变量不传递到的index.php - 访问
/res
(未/res/
! !)突然给我看/res/?uri=res
在我的浏览器中 a nd index.php与uri=res/
。改为访问/res/
,显示我index.php与uri=res/
并且浏览器中的URL保持不变(这是可以的)。
的的.htaccess:
RewriteEngine on
RewriteBase /subthing/
RewriteCond %{REQUEST_URI} !/res/(.+)$
RewriteCond %{REQUEST_URI} !index.php
RewriteRule (.*) index.php?uri=$1
我怎样才能达到预期的行为?
感谢您与'[QSA]'的TIPP。这一工程鳍即这似乎是因为Firefox的'/ res'在URL栏中变成了'/ res /?uri = res'。它不会出现在Firefox中。我想'/ res /'(没有任何尾随的东西)也被重定向到'index.php',你能告诉我如何实现这个吗? – 2012-07-25 12:40:28
@NiklasR这将重定向/ res /如果我没有记错。 Firefox缓存已知的重定向,可能会变得混乱。清除浏览记录,然后请让我知道是否仍有问题。 – 2012-07-25 13:44:35