appending part of REQUEST_URI in redirect url
4 posts
• Page 1 of 1
appending part of REQUEST_URI in redirect url
Hi,
I am using 301 redirects like this.
it's working fine, but what i need is that if the url looks like
www.example.com/view/detail/id/3232/code/A135/anz/5
then the
I am using 301 redirects like this.
- Code: Select all
RewriteMap map txt:redirect.txt
RewriteCond %{HTTP:Host} ^(?:www\.)?example\.com$
RewriteCond %{REQUEST_URI} view/detail/id/(\d+)/(.*)
RewriteCond %{REQUEST_FILENAME} !-F
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule (.*) ${map:%1}? [NC,R=301,L]
it's working fine, but what i need is that if the url looks like
www.example.com/view/detail/id/3232/code/A135/anz/5
then the
part should be appended in redirect URL.code/A135/anz/5
- HeliconAndrew
- Posts: 1264
- Joined: 07 Mar 2012, 10:16
Re: appending part of REQUEST_URI in redirect url
Hello,
Try using:
Regards
Andrew
Try using:
- Code: Select all
RewriteMap map txt:redirect.txt
RewriteCond %{HTTP:Host} ^(?:www\.)?example\.com$ [NC]
RewriteCond %{REQUEST_URI} view/detail/id/(\d+)/(.+)? [NC]
RewriteCond %{REQUEST_FILENAME} !-F
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule (.*) ${map:%1}/?%2%2? [NC,R=301,L]
Regards
Andrew
Re: appending part of REQUEST_URI in redirect url
Hi,
It's working great but unfortunatly could not understand the
for example what we are writing %2 twice
Thank you in advacne.
It's working great but unfortunatly could not understand the
- Code: Select all
/?%2%2?
for example what we are writing %2 twice
Thank you in advacne.
- HeliconAndrew
- Posts: 1264
- Joined: 07 Mar 2012, 10:16
Re: appending part of REQUEST_URI in redirect url
Let's break down it "?%2%2?"a little:
"?%2" - if %2 is there. And we've specified that it may not be there by having '?' at the end "(\d+)/(.+)?"
"%2" - inserts the vaule of (.+)
"?" - prevents appending of original querystring
Regards
Andrew
"?%2" - if %2 is there. And we've specified that it may not be there by having '?' at the end "(\d+)/(.+)?"
"%2" - inserts the vaule of (.+)
"?" - prevents appending of original querystring
Regards
Andrew
4 posts
• Page 1 of 1
Who is online
Users browsing this forum: No registered users and 5 guests