I’ve been working on some projects lately that use server side languages like PHP. I’m pretty comfortable coding, but something that has generally eluded me is as to how I’ve been able to visit sites with URLs like:
http://www.sitename.com/whatever/you/wantWell, I finally came across how to achieve this effect. Enter stage right, HTACCESS.
Apache servers (with mod_rewrite enabled) have the ability to take the request from the user, rewrite it, and then display the rewritten requested page.
1 2 3 4 | RewriteEngine On RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^(.*)$ $1.php [L,QSA] |
This will access the file:
http://www.domain.com/about.phpby typing in the URL of
http://www.domain.com/aboutRespect: Thanks to Dave Dash for this insight into cleaner URLS. Go Green!
To get similar results with an IIS server, visit Micronovae.
Note: that I have a basic understanding of how servers work. For more information about Apache, visit their site.