我想获得带有参数的完整url到index.php,用mod_rewrite重写
.htaccess
RewriteEngine On
RewriteBase /
RewriteCond %{DOCUMENT_ROOT}%{REQUEST_FILENAME} !-f
RewriteCond %{DOCUMENT_ROOT}%{REQUEST_FILENAME} !-d
RewriteRule (.*)$ index.php?q=$1 [L,QSA]
仅index.php
print_r($_GET);
当我尝试时
domain.tld/http://asdf/asdf&s=1%3fb=3&c=34
我明白了
Array
(
[q] => http://asdf/asdf
[s] => 1?b=3
[c] => 34
)
但我需要这样的东西:
Array
(
[q] => http://asdf/asdf&s=1%3fb=3&c=34 //some complicated url
)
有什么(简单的)方法吗?我找到了许多针对不同参数的解决方案,而不是一体化的解决方案。 抱歉我的英语:)
最佳答案
您可以在根 .htaccess 中使用此规则:
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{THE_REQUEST} \s/+(\S+)
RewriteRule ^ /index.php?q=%1 [B,L]
关于php - mod_rewrite 和带有参数的完整 url 作为参数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22155678/