祝大家有美好的一天。任务是在站点上从 /search/all/azazaza 重定向到/search/?query=azazaza 似乎没有什么特别的问题,作为一项规则,我写了这个
RewriteRule ^search/all/* /search/?query=$1 [R=301,L]
我用这个站点来检查规则,这个站点。 当检查站点时,一切都很好,重定向按原样进行......
但是我给服务器写了一条规则,并且重定向传递了但是azazaza参数没有被传输,也就是说,它只是重定向到URL /search/?query= 东西吃掉了azazaza,我不明白是什么,我决定在同一个站点上完全驱动整个 .htaccess 以进行验证(突然间我错过了一些东西......)不,我正在寻找,一切都在站点上正常工作,正确确定重定向并传递参数也正确...但它在服务器上不起作用...告诉我我错过了什么?
完整的.htaccess
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteRule ^search/all/* /search/?query=$1 [R=301,L]
RewriteRule ^extlink-(\d+)(.*)$ extlink.php?n=$1&url=$2 [QSA,L]
RewriteRule ^extlink(/.*)$ extlink.php?url=$1 [QSA,L]
# uncomment the following line, if you are having trouble
# getting no_script_name to work
#RewriteBase /
# we skip all files with .something
#RewriteCond %{REQUEST_URI} \..+$
#RewriteCond %{REQUEST_URI} !\.html$
#RewriteRule .* - [L]
# we check if the .html version is here (caching)
RewriteRule ^$ index.html [QSA]
RewriteRule ^([^.]+)$ $1.html [QSA]
RewriteCond %{REQUEST_FILENAME} !-f
# no, so we redirect to our front web controller
RewriteRule ^(.*)$ index.php [QSA,L]
</IfModule>
您正在尝试替换第一个捕获组
$1,而正则表达式没有它。像这样试试PS 在捕获组中,如果他们来找你,它可能是空的
your.site/search/all/。在这种情况下,它重定向到your.site/search/?query=.