Reputation: 177
I am using this code in my htaccess to rewrite my urls
RewriteRule ([0-9]*)-([^/]*)\.html$ index.php?menu_id=$1&menu=$2 [qsappend]
This rewrites my URL to:
www.site.com/1-home.html
Where 1
is the id(menu_id) and home
is the name of menu.
I have been looking around for a solution where I would be able to rewrite the URLs to:
www.site.com/home.html
Hiding the menu_id part.
Any help will be greatly appreciated
Upvotes: 1
Views: 1892
Reputation: 4271
Here is how.
RewriteRule ([^/]+)\.html$ index.php?menu_id=1&menu=$1 [qsappend]
Edit: You have to compensate for the fact that you won't know the menu id. for instance i put a 1 there, bc i assume you want all your menu id's to be one.
Here is your code broken down:
# here is where your id is located in the code
# | This is the dash in your code
# | | This is your home part
# v v v
RewriteRule ([0-9]*)-([^/]*)\.html$ index.php?menu_id=$1&menu=$2 [qsappend]
# |_____________________| |__________________________|
# Rewrite script
# www.site.com/1-home.html
Upvotes: 1