如何(.htaccess)重写特定搜索查询的网址? [英] How to (.htaccess) rewrite the url of a specific search query?

查看:52
本文介绍了如何(.htaccess)重写特定搜索查询的网址?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我希望(.htaccess)重写具有"custom_title"参数的搜索查询的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)重写特定搜索查询的网址?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆