如何将 search.php?query=test&search=1&s=1 重定向到 /query/test

如何将 search.php?query=test&search=1&s=1 重定向到 /query/test

我尝试过其他方法,但无法让它工作,当我访问主网站时(index.php 只是 search.php 的一个包含),它会将我发送到这个/query/search.php/search.php/search.php/search.php/search.php/search.php/search.php/search.php/search.php/search.php/search.php/search.php/search.php/search.php/search.php/search.php/search.php/search.php/query/?query=search&search=1&s=1&query=search&search=1&s=1&query=search&search=1&s=1&query=search&search=1&s=1&query=search&search=1&s=1&query=search&search=1&s=1&query=search&search=1&s=1&query=search&search=1&s=1&query=search&search=1&s=1&query=search&search=1&s=1&query=search&search=1&s=1&query=search&search=1&s=1&query=search&search=1&s=1&query=search&search=1&s=1&query=search&search=1&s=1&query=search&search=1&s=1&query=search&search=1&s=1&query=query&search=1&s=1 我拥有的 .htaccess 规则是

RewriteEngine on
RewriteRule ^query/([A-Za-z0-9]+) /search.php?query=$1&search=1&s=1  [QSA]

我想search.php?query=test&search=1&s=1转到/query/test/ 更新:在我更新.htaccess 之后说

RewriteEngine on
RewriteRule ^query/([A-Za-z0-9]+) search.php?query=$1&search=1&s=1  [QSA]

它会加载但仍然 /query/search.php/search.php/search.php/search.php/search.php/search.php/search.php/search.php/search.php/search.php/search.php/search.php/search.php/search.php/search.php/search.php/search.php/search.php/query/?query=search&search=1&s=1&query=search&search=1&s=1&query=search&search=1&s=1&query=search&search=1&s=1&query=search&search=1&s=1&query=search&search=1&s=1&query=search&search=1&s=1&query=search&search=1&s=1&query=search&search=1&s=1&query=search&search=1&s=1&query=search&search=1&s=1&query=search&search=1&s=1&query=search&search=1&s=1&query=search&search=1&s=1&query=search&search=1&s=1&query=search&search=1&s=1&query=search&search=1&s=1&query=query&search=1&s=1 有什么想法吗?

答案1

我找到了问题所在,它之所以会这样重定向是因为缓存,我在一个新的浏览器上测试了它,它成功了。我只需要调整一些代码,如果感兴趣的话,我可以在下面留下链接。但我的新 .htaccess 是

#.htaccess for https://sturtz.cf
RewriteEngine on
RewriteRule ^query/([A-Za-z0-9]+)/(1|3) search.php?query=$1&search=1&s=$2  [QSA]
RewriteRule ^query/ search.php [QSA]
RewriteRule ^search.php?query=([A-Za-z0-9]+)&search=1&s=(1|3) /query/$1/$2 [QSA]
RewriteRule ^query/?query=([A-Za-z0-9]+)&search=1&s=1 /query/$1 [QSA]
RewriteRule ^query/?query=([A-Za-z0-9]+)&s=1&activesearch=0 /query/$1 [QSA]
RewriteRule ^query/search.php?query=([A-Za-z0-9]+)&search=1&s=1 /query/$1 [QSA]

相关内容