Alright so this is pretty awesome:
We have just created one or two new WordPress pages using wp-admin – say an “About” page and a “Resume” page. You’ve done all the work to write up all the content, and format it properly and when you publish, the pages look fantastic!
The About and Resume pages have web addresses that look like this:
This is all well and good, but no one is going to remember that our resume is sitting at page_id=99. It would be much more desirable if someone could just type in:
A simple solution, if you are running a newer version of Apache as your web server:
Assuming that we have administrative access to our apache server, and know where our VirtualHost file is, possibly in the /etc/apache2/sites-available/ directory. If you don’t – then stop right here and get a hold of your system administrator! He may have a better solution to this than what you see here ..
Modify the VirtualHost for our blog’s domain so that it would include a RewriteRule that would allow someone to then go to the simpler address, http://www.seevishal.com/resume, and reroute them to the correct WordPress page, which in this case would be http://www.seevishal.com?page_id99.
Here’s what the VirtualHost file for seevishal.com looks like:
ServerName www.seevishal.com ServerAlias seevishal.com *.seevishal.com DocumentRoot /home/seevishal/public_html/ ErrorLog /var/log/apache2/error.log LogLevel warn CustomLog /var/log/apache2/access.log combined ServerSignature On RewriteEngine on RewriteRule ^/resume(.*) http://www.seevishal.com?page_id=99$1 [L] RewriteRule ^/about(.*) http://www.seevishal.com?page_id=116$1 [L]
As you can see, we’ve added three lines towards the bottom. One to turn on the functionality, and two with the RewriteRule settings.
For more reading and examples on how to use RewriteRules, check out
Apache’s Mod Rewrite guide