Rewriting a Url Dynamically
You know how facebook has those urls like facebook.com/example that goes to the page for example? I want to do the same thing. I also want a script to check and see if that name has already been in use. Oh and if the user doesn't set a name then it j开发者_如何学运维ust stays as the normal "more.php?id=4" page. Is this done in the htaccess file or what? Can you point me to any good links on the web that do this?
Question is very vague.
Have a google for apache content negotiation - if you fire a URL like.... http://www.example.com/script.php/something/else
And 'script.php' is a file, then Apache will run script.php (but the full request URL will be available in the $_SERVER variables).
Alternatively, you could set your script as the 404 error handler - then whenever the webserver can't map the URL, it will call your script (again with the request URL in the $_SERVER vars).
While you can as 'the_' suggests use mod_rewrite - there are some obvious drawbacks here - effectively you need to map the request path (or part of it) into the query.
The other approach is to use a reverse proxy such as squid with a URL rewriter script - this could potentially connect to a database backend to get linear mappings.
url rewrite with .htaccess you can search :)
You can find info on Rewrite Guide
精彩评论