Redirecting Old Permalink Structure for Wordpress

ISAPI_Rewrite is Apache mod_rewrite compatible URL rewriter for Microsoft IIS
User avatar
Posts: 5
Joined: 13 Mar 2012, 17:26

Redirecting Old Permalink Structure for Wordpress

13 Mar 2012, 22:24

For starters, I love the new, clean forum look guys, great job. :D

I'm using Isapi Re-write 3 (full version) and want to know what code to install the htaccess for the following permalink structure:
http://www.domain.com/blog/%postname%-%post_id%/ (notice the hyphen and not a / between postname and id)
ex. http://www.domain.com/blog/deep-sea-fishing-1175/


My current permalink structure is http://www.domain.com/blog/%year%/%monthnum%/%postname%/
ex. http://www.domain.com/blog/2012/03/deep-sea-fishing/
In addition to adding the correct rules for the new permalink structure; Is there a line similar to RedirectMatch that will 301 redirect all of the old link structure to the new link structure?

I found a similar idea here: http://yoast.com/change-wordpress-permalink-structure/
But it uses the RedirectMatch rule that Isapi doesn't support. I'm not sure if I used the utility correctly but it gave me this:
RedirectMatch 301 ^/([0-9]{4})/([0-9]{2})/(.*)$ http://www.domain.com/blog/$3


In Summary:
Htaccess Code for:
/%postname%-post_id%/


301 Redirect rule for:
/blog/%year%/%monthnum%/%postname%/ TO /%postname%-post_id%/


Thanks in advance!

User avatar
Posts: 1264
Joined: 07 Mar 2012, 10:16

Re: Redirecting Old Permalink Structure for Wordpress

14 Mar 2012, 08:17

Hello,

For a new URL structure try using the following:

Code: Select all
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(?:[^/-]+)-(\d+)/?$ index.php?p=$1 [NC,L]


Regarding your idea to convert /blog/%year%/%monthnum%/%postname%/ TO /%postname%-post_id%/ there's no way to get PostID form a URL that doesn't have it. You may simply leave the old set of rules for those links to make them work for users coming from other sites.

Regards
Andrew

User avatar
Posts: 27
Joined: 04 Dec 2012, 21:06

Re: Redirecting Old Permalink Structure for Wordpress

04 Dec 2012, 21:19

This doesn't change with regards to the latest update, right?

User avatar
Posts: 1264
Joined: 07 Mar 2012, 10:16

Re: Redirecting Old Permalink Structure for Wordpress

04 Dec 2012, 22:32

No, it doesnt.

Return to ISAPI_Rewrite 3.0

Who is online

Users browsing this forum: No registered users and 14 guests