Rewrite Folders
4 posts
• Page 1 of 1
Rewrite Folders
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
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
Re: Rewrite Folders
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
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
Re: Rewrite Folders
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
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
- HeliconAndrew
- Posts: 1264
- Joined: 07 Mar 2012, 10:16
Re: Rewrite Folders
Hello,
I would find it much easier to use the following rule instead:
regards
Andrew
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
4 posts
• Page 1 of 1
Who is online
Users browsing this forum: No registered users and 8 guests