Link conversion in mod rewrite .htaccess

戏子无情 提交于 2019-12-25 05:49:04

问题


I am trying to change my long url to something short I did it successfully but after sending get info URL is not chanining to what I want like I search for something and it show my url like this

/search.php?q=a&limit=150&siz=any

so I want to convert it automatically in url bar like this

/car/150/any

I am using this

RewriteEngine On
RewriteRule ^([^/]*)/([^/]*)/([^/]*)$ /search.php?q=$1&limit=$2&siz=$3 [R,NC]

but it is not converting link automaticly however it works when I write in url like

/car/150/any

same related question is asked by someone here so I need something like that for my link

Search url automatically in mod_rewrite version

Any help would be appreciated. Thanks


回答1:


Options +FollowSymLinks
RewriteEngine On    
RewriteRule ^search/([^_]+)/([0-9]+)/([^_]+).html$ search.php?act=$1&limit=$2&siz=$3 [L]

access url with

search/car/150/any

better put constant ^search as page identifier to avoiding conflict with other url rewrite,

([^_]+) can receive string input
([0-9]+) only can receive number input


来源:https://stackoverflow.com/questions/23863000/link-conversion-in-mod-rewrite-htaccess

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