URL Rewrite Module Questions

痞子三分冷 提交于 2019-12-12 02:26:10

问题


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

to

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

so $_GET will be

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

How would this rule look like?


回答1:


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.



来源:https://stackoverflow.com/questions/14419658/url-rewrite-module-questions

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!