How to give a WordPress Page a memorable address using Apache’s RewriteRules
January 5, 2011
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: http://www.cabanalabs.com?page_id=99
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: http://www.cabanalabs.com/resume
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: