Redirect Loop issue for Rewrite and Redirect to same page
4 posts
• Page 1 of 1
- davideastes
- Posts: 2
- Joined: 03 Mar 2016, 22:52
Redirect Loop issue for Rewrite and Redirect to same page
I am trialling the effects of a URL rewrite on one version of one of our pages. Goal 1 does work but adding in Goal 2 creates a redirect loop. Any ideas on how this can be achieved?
GOAL 1: Rewrite (DONE)
Setup http://www.cleancruising.com.au/cruisel ... rica-line/ as a rewrite of http://www.cleancruising.com.au/cruiseline.asp?id=HAL
GOAL 2: Redirect
301 Redirect ALL traffic from http://www.cleancruising.com.au/cruiseline.asp?id=HAL over to the new page at http://www.cleancruising.com.au/cruisel ... rica-line/
CURRENT CODE:
# Helicon Ape version 3.1.0.248
RewriteEngine On
RewriteBase /
RewriteRule ^cruiseline/holland-america-line/ /cruiseline.asp?id=HAL [NC, L]
RewriteCond %{QUERY_STRING} ^id=HAL
RewriteRule ^cruiseline\.asp$ /cruiseline/holland-america-line/? [NC,R=301]
GOAL 1: Rewrite (DONE)
Setup http://www.cleancruising.com.au/cruisel ... rica-line/ as a rewrite of http://www.cleancruising.com.au/cruiseline.asp?id=HAL
GOAL 2: Redirect
301 Redirect ALL traffic from http://www.cleancruising.com.au/cruiseline.asp?id=HAL over to the new page at http://www.cleancruising.com.au/cruisel ... rica-line/
CURRENT CODE:
# Helicon Ape version 3.1.0.248
RewriteEngine On
RewriteBase /
RewriteRule ^cruiseline/holland-america-line/ /cruiseline.asp?id=HAL [NC, L]
RewriteCond %{QUERY_STRING} ^id=HAL
RewriteRule ^cruiseline\.asp$ /cruiseline/holland-america-line/? [NC,R=301]
Re: Redirect Loop issue for Rewrite and Redirect to same pag
Hello.
Add an NS flag to redirect rule to prevent from calling it on subrequests:
RewriteCond %{QUERY_STRING} ^id=HAL
RewriteRule ^cruiseline\.asp$ /cruiseline/holland-america-line/? [NS,NC,R=301]
Add an NS flag to redirect rule to prevent from calling it on subrequests:
RewriteCond %{QUERY_STRING} ^id=HAL
RewriteRule ^cruiseline\.asp$ /cruiseline/holland-america-line/? [NS,NC,R=301]
- davideastes
- Posts: 2
- Joined: 03 Mar 2016, 22:52
Re: Redirect Loop issue for Rewrite and Redirect to same pag
Yaroslav. You are fantastic.
This worked a treat. Well done. Really appreciate this as I was completely unaware of the NS flag. I will read up on the documentation.
THANK YOU!
This worked a treat. Well done. Really appreciate this as I was completely unaware of the NS flag. I will read up on the documentation.
THANK YOU!
Re: Redirect Loop issue for Rewrite and Redirect to same pag
You're welcome!
This is to comply with Apache mod_rewrite behavior - every time config results into a change of URL, new internal subrequest is called starting all rules sequence with new URL again. This can result in a loop if one rule takes the same pattern that other generates, which is sometimes useful, but need to be screened out with NS flag when undesired.
This is to comply with Apache mod_rewrite behavior - every time config results into a change of URL, new internal subrequest is called starting all rules sequence with new URL again. This can result in a loop if one rule takes the same pattern that other generates, which is sometimes useful, but need to be screened out with NS flag when undesired.
4 posts
• Page 1 of 1
Who is online
Users browsing this forum: No registered users and 20 guests