Wordpress Wednesdays: Permanent Redirect of Posts
Posted on November 28th, 2007
Many people may not know that Beyond the Rhetoric was originally hosted by GoDaddy and made use of their free QuickBlog software. It was very restrictive and that’s why I eventually moved the blog to Wordpress. Unfortunately for me, the default permalink structure with QuickBlog came with an .aspx extension for every post.
I wanted to keep any backlinks that I had, so I continued with the same permalink structure in Wordpress until just recently. I’ve been meaning to ditch the .aspx extension for some time, but I never really knew how. After all, none of my posts are actually in aspx. I didn’t want to lose backlinks, so I had to figure out a way to set up a permanent 301 redirect for all the posts. For that, I asked Matt for some help and he came through with flying colors.
As Matt described it, the code below is designed “so /2007/11/19/post-title.aspx permanently [301] redirects to /2007/11/19/post-title/”. The first part is to go into Wordpress and adjust the information in options/permalinks to the date/post-title structure. The second part is to insert this code into your .htaccess file, somewhere above the “# BEGIN WordPress” line.
# START Redirection of .aspx Extension
RewriteEngine On
RewriteBase /
RewriteRule ^/?([-a-zA-Z0-9/]+)\.aspx$ $1/ [R=301,L]
# END Redirection of .aspx Extension
I’ve implemented Matt’s code and it works like a charm. I’d imagine that the code would be nearly identical if you wanted to go from a /post-title.php permalink structure to a /post-title/ structure.
Posted in WordPress | 910 views | | Digg This | del.icio.us | Technorati
Related Topics:
600 Twitter Followers
Wordpress Wednesdays: Related Posts
Wordpress Wednesdays: Use Drafts to Your Advantage
Top 10 WordPress Plug-Ins of 2008
900 Twitter Followers
1 Comment
Sorry, the comment form is closed at this time.
Great idea. Congrats on making the move. It’s hard to find someone who can help you out for free, count yourself lucky.