Having just set up WordPress I wanted to get a few things up and going that would make this site search engine and human friendly. One of these is creating meaningful permalinks for your blog posts. WordPress has some great defaults but I like a more custom URL, like this page’s URL for instance has the post id number followed by title in the URL. I want this for two reasons:
- It lets people easily identify the page from it’s URL
- It gives those words extra meaning in Google’s algorithm
On the WordPress side, all you have to do is go to the Dashboard>Settings>Permalinks and select “Custom Structure” and enter in:
When you click “Save Changes” the page will generate a .htaccess output on the bottom which you then copy and paste into the file and upload it to your blog’s root directory. The only issue is that Apache on Ubuntu Server doesn’t have .htaccess enabled by default.
Here is what you need to do:
Open up Ubuntu Server’s terminal or Putty into your machine. Next get to your configuration file for your site (usually named “default”) and open it for editing:
cd /etc/apache2/sites-available sudo vi default
Find the section that looks like this:
<Directory /var/www/> Options Indexes FollowSymLinks MultiViews AllowOverride None Order allow,deny allow from all </Directory>
Edit it to:
<Directory /var/www/> Options Indexes FollowSymLinks MultiViews AllowOverride All Order allow,deny allow from all </Directory>
Here we are changing the AllowOverride value to All to allow the .htaccess files to effect how the server acts.
Now test the site. If you get a 500 error you will need to do one more step and create a config file for the rewrite rule. Again in terminal/Putty, go to the modules’ folder and create/edit a file named rewrite.conf:
cd /etc/apache2/mods-enabled/ sudo vi rewrite.conf
In this file; copy this line:
LoadModule rewrite_module /usr/lib/apache2/modules/mod_rewrite.so
Now all you have to do is restart Apache by running this line:
sudo /etc/init.d/apache2 restart
Now go to your site and see your WordPress Blog come back to life! Click around and make sure your links to the individual articles and static pages/feeds are still in working order.
Now you are one step closer to a super Google and human friendly blog!