如何 (.htaccess) 重写特定搜索查询的 url? [英] How to (.htaccess) rewrite the url of a specific search query?
本文介绍了如何 (.htaccess) 重写特定搜索查询的 url?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
当搜索查询具有custom_title"参数时,我希望 (.htaccess) 重写它的 url.任何人都可以帮助我吗?我想重写这个网址:
I wish to (.htaccess) rewrite the url of a search query when it has the "custom_title" parameter. Anyone can help me? I'd like to rewrite this url:
http://www.mysite.com/search.php?search_query=myquery&custom_title=mytitle
为此:
http://www.mysite.com/results/myquery/mytitle/
推荐答案
通过 httpd.conf
启用 mod_rewrite 和 .htaccess 然后把这段代码放到你的 .htaccess
下DOCUMENT_ROOT
目录:
Enable mod_rewrite and .htaccess through httpd.conf
and then put this code in your .htaccess
under DOCUMENT_ROOT
directory:
Options +FollowSymLinks -MultiViews
# Turn mod_rewrite on
RewriteEngine On
RewriteBase /
RewriteRule ^results/([^/]+)/([^/]+)/?$ /search.php?search_query=$1&custom_title=$2 [L,NC,QSA]
这篇关于如何 (.htaccess) 重写特定搜索查询的 url?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文