Wednesday, 21 February 2007
Tidy URL Rewrites with PHP |
| |
|
| |
Tim Bromhead, in a new entry over the bla.st blog, talks about writing neat and tidy URLs with PHP. He says, to do this you have to set up URL rewrites in Apache to send all page requests through a single PHP script. In this post he shows you, how to make the URLs with spaces easy to type for users.
He gives an instance of his site bla.st which uses dashes in the URLs to represent spaces for example—http//bla.st/web-design/. He explains that, dashes were chosen over underscores because underscores can get lost with underlined links.
He points out the following ways to write a space in a URL:
- Underscore
eg /web_design/ - A proper space
eg. /web design/ - The code for a space
%20 eg. /web%20design/ - Or a dash
eg. /web-design/
He says, the priority is to make sure the URL rewrites are setup to handle spaces, underscores and dashes. He illustrates with an example code to set up the http.conf virtual host entry. He follows up this process by saying that if this is set up right, after restarting Apache all requests will go through index.php. A code example clarifies the startup of the index.php file.
He concludes by saying that the end result will be the following URLs and all will be automatically converted for the user, so he says, it doesn't matter what format they use:
http://www.bla.st/web%20design/ http://asdf.bla.st/graphic_design/ http://bla.st/web 2.0/ http://bla.st/mac-software/
|
| |
|
Read the Post
|
| |
|
|
| |
|
|
| |
|