Nick Nick - 1 year ago 91
PHP Question

htaccess rule for slash(/) in place of dash(-)

I have a htaccess rule as follows:

RewriteRule ^restaurant-([0-9_-]+)-([a-zA-Z0-9_-]+)-([a-zA-Z0-9_-]+)-menu$ rest_menu?&id=$1&area=$2&Name=$3

The url is as follows:

But I want the url to be

How do I change my htaccess rule so that it starts working.

Notice: the "- " before menu is replaced by "/".

Answer Source

Use this rule i am assuming rest_menu is a php file.

Options -Multiviews
RewriteEngine on
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^restaurant-([\d]+)-([\w-]+)-([\w-]+)/menu$ rest_menu.php?&id=$1&area=$2&Name=$3 [QSA,L]
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download