Rewrite Folders

ISAPI_Rewrite is Apache mod_rewrite compatible URL rewriter for Microsoft IIS
User avatar
Posts: 3
Joined: 30 May 2012, 23:24

Rewrite Folders

30 May 2012, 23:30

Hello.

We have several a lot of urls that we need to correct, and I am trying to do so using a map file.

As an example, the url we have is:

http://wilmington.insiderinfo.us/restau ... dley-creek

And the url we want is:

http://wilmington.insiderinfo.us/restau ... dley-creek

The difference being that 'oleander' was misspelled initially.

So I have tried a map file using both methods below:

restaurants-in-wilmington-nc/oldeander-independence-bradley-creek restaurants-in-wilmington-nc/oleander-independence-bradley-creek
oldeander-independence-bradley-creek oleander-independence-bradley-creek

With the follow rewrite rule:


RewriteCond $(old_map_subchapter:$0|NOT_FOUND} !NOT_FOUND
RewriteRule ^([A-Za-z0-9-]+)/([A-Za-z0-9-]+)/?$ /${old_map_subchapter:$0} [NC,R=301]

Variations have included


RewriteCond $(old_map_subchapter:$2|NOT_FOUND} !NOT_FOUND
RewriteRule ^([A-Za-z0-9-]+)/([A-Za-z0-9-]+)/?$ /$1/${old_map_subchapter:$2} [NC,R=301]

But neither of those have worked.

Can anyone suggest a method that might work?

Thanks,
Alex

User avatar
Posts: 3
Joined: 30 May 2012, 23:24

Re: Rewrite Folders

30 May 2012, 23:43

As a follow up, this simple rule works:

RewriteRule ^restaurants-in-wilmington-nc/oldeander-independence-bradley-creek/?$ /restaurants-in-wilmington-nc/oleander-independence-bradley-creek/ [NC,R=301]

But there are so many URLs that I need to be able to dynamically generate the mapfile.

thanks to any who help!
thanks,
alex

User avatar
Posts: 3
Joined: 30 May 2012, 23:24

Re: Rewrite Folders

31 May 2012, 00:21

Hmmm. Oddly enough it will work one time, but not others . . . . . there are other rules in there though . . . .

EDIT:

If I load up the desired URL (w/ oleander), and then add the 'd' to cause the redirect, it works once, but doesn't work on subsequent trials.

Any help or suggestion is appreciated,

thanks,
alex

EDIT:

Ok, so that had to do with the trailing slash. Now I've got it working with this configuration:

RULE:


RewriteCond ${old_map_subchapter:$0|NOT_FOUND} !NOT_FOUND
RewriteRule ^([A-Za-z0-9-]+)/([A-Za-z0-9-]+)/?$ /${old_map_subchapter:$0}/ [NC,R=301]

MAPFILE:


restaurants-in-wilmington-nc/oldeander-independence-bradley-creek restaurants-in-wilmington-nc/oleander-independence-bradley-creek
restaurants-in-wilmington-nc/oldeander-independence-bradley-creek/ restaurants-in-wilmington-nc/oleander-independence-bradley-creek

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

Re: Rewrite Folders

31 May 2012, 06:32

Hello,

I would find it much easier to use the following rule instead:

Code: Select all
RewriteCond ${old_map_subchapter:$0|NOT_FOUND} !NOT_FOUND
RewriteRule ^([^/]+/[^/]+)/?$ /${old_map_subchapter:$1}/ [NC,R=301,L]

regards
Andrew

Return to ISAPI_Rewrite 3.0

Who is online

Users browsing this forum: No registered users and 8 guests