Twitter has ignited new era, an era of URL shorten-er service like tinyurl or bit.ly and many more but then I was thinking about doing something of my own. No no no don't worry it is not yet another URL shorten-er service but it will be to make your Wordpress URL's shorter and using your own domain name in it. If you are using hosted Wordpress blog and have some permalinks structure defined you will have the following in your .htaccess file
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
Now add the following just above that.
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{HTTP_HOST} ^codeitwell\.com$ [NC]
RewriteRule ^([0-9]+)([\/]?)$ http://www.codeitwell.com/?p=$1 [S=1]
</IfModule>
It assumes that your non-www version of the url does not have anything and can be used for URL shortening. If not you can create any other sub-domain for the same. Remember to change codeitwell.com to your domain name.
Example
Explanation
RewriteCond %{HTTP_HOST} ^codeitwell\.com$ [NC]
Only Applies the RewriteRule for non-www host. This is optional line and can be avoided. If you avoid this line the redirect will work for all hosts. i.e. www and non-www.
RewriteRule ^([0-9]+)([\/]?)$ http://www.codeitwell.com/?p=$1 [S=1]
Checks if its only numbers and redirects to the post URL. Remember [S=1] is very important because it skips the next RewriteRule which is for the default Wordpress permalinks rule which need not be executed any more.
- Blogspot Vs Wordpress
- SEO for Wordpress Categories
- Wordpress as CMS
- AWeber Footer SlideUp – My First Wordpress Plugin
- 20 Essential Wordpress Plugins
Enter your Name and Email below to subscribe and start 1 month free course now.









