我正在使用Apache rewrite_mod在URL地址使用.htaccess文件中的以下内容进入参数文本后进行所有测试
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?text=$1 [L,QSA]
如果我有www.example.com/some_text
则有效
但是当我有www.example.com/some_text/some other text
我想在text参数中有整个请求:“some_text / some other text” 不仅是“其他一些文字”。
可以这样做吗?
答案 0 :(得分:2)
我让apache / php对此进行排序:
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php [L]
PHP会在$ _SERVER
中存储您可能需要的所有信息$_SERVER['REQUEST_URI'] // Original uri with original query string
$_SERVER['REDIRECT_QUERY_STRING'] // Original query string
$_SERVER['REDIRECT_URL'] // Original uri without query string
此方法将保留$ _GET / $ _POST / $ _REQUEST等。
答案 1 :(得分:0)
我正在使用它,它完美无缺:
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule (.*) index.php/$0 [PT,L]
答案 2 :(得分:0)
$_SERVER['QUERY_STRING']
将包含查询字符串。