Help rewriting url [duplicate]
Possible Duplicate:
Please URL Rewrite in php
I would like visitors to access the page by typing www.site.com/12
instead of www.site.com/room/doorstep.php?page_id=12
The IDs are many so i cannot create folders.
What is the code needed to do this?
I am trying to do this through .htaccess
but I have not been successfull.
Please help me with this.
Dennis.
The problem with the www.site.com/12
setup, is it makes it a bit tricky to do, as if you want to actually add a physical page called 1000
your setup may not work right (which may also depend on multiviews). Instead I would steer away from that and do something like:
www.site.com/room/12
or www.site.com/room/id/12
The .htaccess
redirect for that would be something like:
RewriteRule ^room/id/(.*)$ room/doorstep.php?page_id=$1 [L]
That should give you the example you need to get the show on the road.
EDIT
What might even be better is just match a number:
RewriteRule ^room/id/([0-9]+)$ room/doorstep.php?page_id=$1 [L]
Which would only return true if a number was passed, since that is what your ID's seem to consist of.
Assuming you've got mod_rewrite
set up in Apache, you can do the following in your .htaccess
RewriteEngine On
RewriteRule ^([0-9]+)$ room/doorstep.php?page_id=$1 [L]
精彩评论