问题
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