URL重写模块问题 [英] URL Rewrite Module Questions

查看:102
本文介绍了URL重写模块问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在htaccess文件中创建一个重写模块,如下所示:

I want to make a rewrite module in htaccess file something like below

http://example.com/index.php?tel=604-567-0909&cat=1&sort=2

http://example.com/604-567-0909/?cat=1&sort=2

所以$_GET将是

$_GET[tel] = 604-567-0909
$_GET[cat] = 1 
$_GET[sort] = 2

这条规则看起来如何?

推荐答案

如果您只想在tel字段中接受数字和破折号,它将看起来像这样:

It would look like this if you only wanted to accept numbers and dashes in the tel field:

RewriteRule ^/?([0-9\-]+)/$ index.php?tel=$1 [L]

查询字符串中的其他值将自动保留,如果没有很好的效果,此规则将起作用.

The other values in the query string would be carried over automatically, and this rule would work without them just fine.

这篇关于URL重写模块问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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