我正在使用 PHP Fat-Free 框架(http://fatfree.sourceforge.net/) 来开发一个网站,我需要使用 GET 变量,但它们无法解析,因为我正在使用 Mod Rewrite。
这是我的 .htaccess 文件的当前状态:
# Enable rewrite engine and route requests to framework
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-l
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule .* index.php [L,QSA]
目前,我可以通过 www.domain.com/mypage 请求带有框架的页面,但我需要使用诸如 www.domain.com/mypage?variable=xyz 之类的网址
有什么办法可以解决这个问题吗?提前致谢!
编辑:
我使用了级别为 3 的重写日志并请求 www.domain.com/?x=1,日志中的内容如下:
::1 - - [21/Aug/2010:21:09:28 +1200] [localhost/sid#1545150][rid#2054260/initial] (3) [perdir D:/Development/xampplite/htdocs/] strip per-dir prefix: D:/Development/xampplite/htdocs/ ->
::1 - - [21/Aug/2010:21:09:28 +1200] [localhost/sid#1545150][rid#2054260/initial] (3) [perdir D:/Development/xampplite/htdocs/] applying pattern '.*' to uri ''
::1 - - [21/Aug/2010:21:09:28 +1200] [localhost/sid#1545150][rid#2054260/initial] (1) [perdir D:/Development/xampplite/htdocs/] pass through D:/Development/xampplite/htdocs/
::1 - - [21/Aug/2010:21:09:28 +1200] [localhost/sid#1545150][rid#205a278/subreq] (3) [perdir D:/Development/xampplite/htdocs/] strip per-dir prefix: D:/Development/xampplite/htdocs/index.php -> index.php
::1 - - [21/Aug/2010:21:09:28 +1200] [localhost/sid#1545150][rid#205a278/subreq] (3) [perdir D:/Development/xampplite/htdocs/] applying pattern '.*' to uri 'index.php'
::1 - - [21/Aug/2010:21:09:28 +1200] [localhost/sid#1545150][rid#205a278/subreq] (1) [perdir D:/Development/xampplite/htdocs/] pass through D:/Development/xampplite/htdocs/index.php
::1 - - [21/Aug/2010:21:09:28 +1200] [localhost/sid#1545150][rid#2058270/initial] (3) [perdir D:/Development/xampplite/htdocs/] strip per-dir prefix: D:/Development/xampplite/htdocs/favicon.ico -> favicon.ico
::1 - - [21/Aug/2010:21:09:28 +1200] [localhost/sid#1545150][rid#2058270/initial] (3) [perdir D:/Development/xampplite/htdocs/] applying pattern '.*' to uri 'favicon.ico'
::1 - - [21/Aug/2010:21:09:28 +1200] [localhost/sid#1545150][rid#2058270/initial] (2) [perdir D:/Development/xampplite/htdocs/] rewrite 'favicon.ico' -> 'index.php'
::1 - - [21/Aug/2010:21:09:28 +1200] [localhost/sid#1545150][rid#2058270/initial] (3) [perdir D:/Development/xampplite/htdocs/] add per-dir prefix: index.php -> D:/Development/xampplite/htdocs/index.php
::1 - - [21/Aug/2010:21:09:28 +1200] [localhost/sid#1545150][rid#2058270/initial] (2) [perdir D:/Development/xampplite/htdocs/] trying to replace prefix D:/Development/xampplite/htdocs/ with /
::1 - - [21/Aug/2010:21:09:28 +1200] [localhost/sid#1545150][rid#2058270/initial] (1) [perdir D:/Development/xampplite/htdocs/] internal redirect with /index.php [INTERNAL REDIRECT]
::1 - - [21/Aug/2010:21:09:28 +1200] [localhost/sid#1545150][rid#3b68870/initial/redir#1] (3) [perdir D:/Development/xampplite/htdocs/] strip per-dir prefix: D:/Development/xampplite/htdocs/index.php -> index.php
::1 - - [21/Aug/2010:21:09:28 +1200] [localhost/sid#1545150][rid#3b68870/initial/redir#1] (3) [perdir D:/Development/xampplite/htdocs/] applying pattern '.*' to uri 'index.php'
::1 - - [21/Aug/2010:21:09:28 +1200] [localhost/sid#1545150][rid#3b68870/initial/redir#1] (1) [perdir D:/Development/xampplite/htdocs/] pass through D:/Development/xampplite/htdocs/index.php
不确定这是否有帮助?
答案1
QSA 的工作原理并非如此,请参见此处flags_qsa。我认为您需要捕获新的查询字符串,因为您没有现有的查询字符串。
尝试这样的事情
# Enable rewrite engine and route requests to framework
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-l
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule (.*) index.php?$1 [L,QSA]
您可能需要根据重写规则所在的位置添加/
前导。index.php?$1
答案2
该QSA
标志应该已经处理了这个问题。激活您的重写日志并查看 URL 内部是如何重写的。