如何使用 mod_rewrite 将查询字符串转换为路径 URL? [英] How to convert querystring to paths URL using mod_rewrite?

查看:24
本文介绍了如何使用 mod_rewrite 将查询字符串转换为路径 URL?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试将具有查询字符串的 URL 重写为其 SEO 友好名称,即考虑

I'm trying to rewrite a URL that has a query string to its SEO friendly name i.e. consider

mysite.com/models?p1=v1

我想改写为

mysite.com/models/p1/v1

用户应该在地址栏中看到上面的地址.有什么建议吗?

The user should see the above address in address bar. Any suggesstions?

推荐答案

.htaccess 应该是:

RewriteEngine On
RewriteRule ^models/(.+)/(.+)$ models.php?$1=$2 [NC,L]

这篇关于如何使用 mod_rewrite 将查询字符串转换为路径 URL?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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