If you’re like us and you’ve always wanted to learn how to provide simple or clean urls, while still maintaining an easy .php or .asp setup in your main directory, you can do so easily with an .htaccess file. (For you apache guys/gals).

Special thanks to corz.org for their great .htaccess rewrite article.

So, you have:

http://somesite.com/services.php

and you’d like your visitors to type:

http://somesite.com/services

Solution

1. Paste the following in your .htaccess file:


Options +FollowSymlinks
RewriteEngine on
RewriteRule ^services services.php

Looking at the third line only:

  • Rewrite
  • ^services = what will appear after your domain name (e.g. http://somesite.com/services)
  • services.php = the actual page in your structure

And voila! Add as many lines as you like to this file. An example .htaccess file, for a small site might look like:

Options +FollowSymlinks
RewriteEngine on
RewriteRule ^services services.php
RewriteRule ^technology technology.php
RewriteRule ^contact contact.php
RewriteRule ^vendors vendor-registration.php
RewriteRule ^hospitals hospital-registration.php

More Information on .htaccess

Leave a Reply