Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/url/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
.htaccess 如何使用mod_rewrite为搜索重写动态url?_.htaccess_Url_Mod Rewrite_Redirect_Rewrite - Fatal编程技术网

.htaccess 如何使用mod_rewrite为搜索重写动态url?

.htaccess 如何使用mod_rewrite为搜索重写动态url?,.htaccess,url,mod-rewrite,redirect,rewrite,.htaccess,Url,Mod Rewrite,Redirect,Rewrite,我有一个网上商店,里面有一个搜索栏。当我搜索时,我被转发到如下链接: webshopdomain.com/index.php?route=product/search&keyword=my搜索短语 更像是这样:webshopdomain.com/index.php?route=product/search&keyword=my%20search%20phrase 我需要在htaccess中输入什么才能使此url:webshopdomain.com/search/my%20search%20phr

我有一个网上商店,里面有一个搜索栏。当我搜索时,我被转发到如下链接:

webshopdomain.com/index.php?route=product/search&keyword=my搜索短语

更像是这样:webshopdomain.com/index.php?route=product/search&keyword=my%20search%20phrase

我需要在htaccess中输入什么才能使此url:webshopdomain.com/search/my%20search%20phrase显示上述url的内容

我一直在玩这个工具,但不知道如何抓取搜索短语并将其放入静态url

我也在谷歌上搜索,但由于缺乏正确的措辞,我还没有找到答案

谢谢:-

编辑:

我能用这个吗?只是想了想,要测试一下

Options +FollowSymLinks
RewriteEngine on
RewriteRule search/(.*) index.php?route=product/search&keyword=$1
RewriteRule search/(.*)/ index.php?route=product/search&keyword=$1

要避免递归,您需要查看以下内容:


这非常简单,但必须重新安排htaccess文件本身


重写规则^search/*$index.php\?route=product/search&keyword=$1

你好,谢谢:-我试过了,但没有成功。是否可以将整个index.php?route=product/search&keyword=作为url的一部分,然后将后面的所有内容都作为新url中的一个参数?
RewriteCond %{THE_REQUEST} ^GET\ /index\.php\?route=product/search&keyword=([^&\ ]*)&*([^\ ]+)?
RewriteRule ^index\.php$ /search/%1?%2 [L,R=301]