Mod_Rewrite .Htaccess

孤街醉人 提交于 2019-12-13 04:39:33

问题


I have a problem which I could not find during my online search.

I have successfully made a wildcard sub-domain and any sub domain to the main domain points to the folder.

I am looking to create link URI to Parameters like

1- .domain.com/location/locationname to 2- .domain.com//location.php? locname=

and then

1- .domain.com/location/locationname/category/categoryname/item/itemname to 2- .domain.com//orderitem.php?locname=locationname&ordercategory=categoryname&orderitem=itemname

(2) is happening in the backend and user still sees (1)

How will it work? Do I have to make table in MySQL, which I am not sure how it will go around. Second is to explode the URL and link to specific URL like orderloc or ordermenu or orderitem etc.

Any help will be a step closer.

Thanks


回答1:


This should work:

RewriteEngine On
RewriteRule ^location/(.*)/category/(.*)/item/(.*) //orderitem.php?locname=$1&ordercategory=$2&orderitem=$3\? [L]
RewriteRule ^location/(.*) //location.php?locname=\? [L]

It will show domain.com/location/locationname to the user, but the backend will see `domain.com//location.php?locname=

and domain.com/location/locationname/category/categoryname/item/itemname to the user, but the backend will see domain.com//orderitem.php?locname=locationname&ordercategory=categoryname&orderitem=itemname



来源:https://stackoverflow.com/questions/22889136/mod-rewrite-htaccess

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