Consecutive RewriteRule (conversion by 2.0 ver)
11 posts
• Page 1 of 1
Consecutive RewriteRule (conversion by 2.0 ver)
I'v convert from ISAPI 2.x ti Isapi 3.x with our tools.
I'v theese new (not working) rules (my rules are more complex, but i'v simpilfied):
RewriteCond %{HTTP:Host} ^(?:.*)\.domain\..*$
RewriteCond %{REQUEST_URI} ^/test$
RewriteRule .* /page.htm
RewriteCond %{HTTP:Host} ^(?:.*)\.domain\..*$
RewriteCond %{REQUEST_URI} ^/page.htm$
RewriteRule .* /newpage.htm
First step: /test > page.htm
Second step: /page.htm > /NewPage.htm
Second RewriteCond refer to "original" RequestUri, not to rewritten URI.
OLD Rules (2.x) was in this format, and work fine:
RewriteCond Host: (?:.*)\.domain\..*
RewriteCond URL /url
RewriteRule .* /page.htm
can you help me, please ?
regards
Marco Li Mandri
I'v theese new (not working) rules (my rules are more complex, but i'v simpilfied):
RewriteCond %{HTTP:Host} ^(?:.*)\.domain\..*$
RewriteCond %{REQUEST_URI} ^/test$
RewriteRule .* /page.htm
RewriteCond %{HTTP:Host} ^(?:.*)\.domain\..*$
RewriteCond %{REQUEST_URI} ^/page.htm$
RewriteRule .* /newpage.htm
First step: /test > page.htm
Second step: /page.htm > /NewPage.htm
Second RewriteCond refer to "original" RequestUri, not to rewritten URI.
OLD Rules (2.x) was in this format, and work fine:
RewriteCond Host: (?:.*)\.domain\..*
RewriteCond URL /url
RewriteRule .* /page.htm
can you help me, please ?
regards
Marco Li Mandri
Re: Consecutive RewriteRule (conversion by 2.0 ver)
Hi, have you read my post ?
thank you,
best regards
Marco Li Mandri
thank you,
best regards
Marco Li Mandri
- HeliconAndrew
-
- Posts: 1264
- Joined: 07 Mar 2012, 10:16
Re: Consecutive RewriteRule (conversion by 2.0 ver)
Are you looking for rewrite or redirect?
Regards
Andrew
Regards
Andrew
Re: Consecutive RewriteRule (conversion by 2.0 ver)
Only Rewrite.
End user type "www.domain.com/page"
First rewrite transform URL in www.domain.com/section/typecontent.chtm
Second series of rewrite rule trasform every *.chtm in real page page.aspx?parameter...
For this reason i nedd 2 consecutive REWRITE.
Thank you
Best regards
MLM
End user type "www.domain.com/page"
First rewrite transform URL in www.domain.com/section/typecontent.chtm
Second series of rewrite rule trasform every *.chtm in real page page.aspx?parameter...
For this reason i nedd 2 consecutive REWRITE.
Thank you
Best regards
MLM
- HeliconAndrew
-
- Posts: 1264
- Joined: 07 Mar 2012, 10:16
Re: Consecutive RewriteRule (conversion by 2.0 ver)
I would try:
However, based on what I understood, you may want to use HTTP_X_REWRITE_URL instead of REQUEST_URI in the second rule. The meaning of this variable is described here - http://www.helicontech.com/isapi_rewrite/doc/concept.htm.
Another useful feature in ISAPI_Rewrite 3 is the logs. We can enable logging (described in FAQ - http://www.helicontech.com/forum/10648-FAQ.html) and see the way the request is being processed in rewrite.log.
Regards
Andrew
- Code: Select all
RewriteCond %{HTTP:Host} ^(?:[^.]+\.)?domain\..*$
RewriteCond %{REQUEST_URI} ^/test$ [NC]
RewriteRule .* /page.htm
RewriteCond %{HTTP:Host} ^(?:[^.]+\.)?domain\..*$
RewriteCond %{REQUEST_URI} ^/page\.htm$ [NC]
RewriteRule .* /newpage.htm
However, based on what I understood, you may want to use HTTP_X_REWRITE_URL instead of REQUEST_URI in the second rule. The meaning of this variable is described here - http://www.helicontech.com/isapi_rewrite/doc/concept.htm.
Another useful feature in ISAPI_Rewrite 3 is the logs. We can enable logging (described in FAQ - http://www.helicontech.com/forum/10648-FAQ.html) and see the way the request is being processed in rewrite.log.
Regards
Andrew
Re: Consecutive RewriteRule (conversion by 2.0 ver)
HTTP_X_REWRITE_URL contains value of URL before modification.
I Need value AFTER modification, but REQUEST_URI contain original value instead rewritten value, every.
I've enabled rewritelog.
I've tested theese rules (on Win 2012 Server):
------------------
RewriteCond %{HTTP:Host} ^(?:.*)\.negozioelettronico\..*$
RewriteCond %{REQUEST_URI} ^/test$
RewriteRule .* /page\.htm
RewriteCond %{HTTP:Host} ^(?:.*)\.negozioelettronico\..*$
RewriteCond %{REQUEST_URI} ^/page\.htm$
RewriteRule .* /newpage.htm
RewriteCond %{HTTP:Host} ^(?:.*)\.negozioelettronico\..*$
RewriteCond %{HTTP_X_REWRITE_URL} ^/page\.htm$
RewriteRule .* /newpage.htm
RewriteCond %{HTTP:Host} ^(?:.*)\.negozioelettronico\..*$
RewriteCond %{URL} ^/page\.htm$
RewriteRule .* /newpage.htm
-----------
First RULE work Fine, after First RULE the variable "REQUEST_URI" remain with Original VALUE, and REQUEST_URI have same value of HTTP_X_REWRITE_URL.
(3) applying pattern '.*' to uri '/test'
(4) RewriteCond: input='srcdemo.negozioelettronico.it' pattern='^(?:.*)\.negozioelettronico\..*$' => matched
(4) RewriteCond: input='/test' pattern='^/test$' => matched
(1) Rewrite URL to >> /page.htm
(2) rewrite '/test' -> '/page.htm'
(3) applying pattern '.*' to uri '/page.htm'
(4) RewriteCond: input='srcdemo.negozioelettronico.it' pattern='^(?:.*)\.negozioelettronico\..*$' => matched
(4) RewriteCond: input='/test' pattern='^/page\.htm$' => not-matched <<<<<<<<<<<<<<<<<<<<<<<<<< should be value of "input" variable set to "page.htm" ?
May be a bug or misconfiguration ?
(3) applying pattern '.*' to uri '/page.htm'
(4) RewriteCond: input='srcdemo.negozioelettronico.it' pattern='^(?:.*)\.negozioelettronico\..*$' => matched
(4) RewriteCond: input='/test' pattern='^/page\.htm$' => not-matched
(3) applying pattern '.*' to uri '/page.htm'
(4) RewriteCond: input='srcdemo.negozioelettronico.it' pattern='^(?:.*)\.negozioelettronico\..*$' => matched
(4) RewriteCond: input='/test' pattern='^/page\.htm$' => not-matched
regards
MLM
I Need value AFTER modification, but REQUEST_URI contain original value instead rewritten value, every.
I've enabled rewritelog.
I've tested theese rules (on Win 2012 Server):
------------------
RewriteCond %{HTTP:Host} ^(?:.*)\.negozioelettronico\..*$
RewriteCond %{REQUEST_URI} ^/test$
RewriteRule .* /page\.htm
RewriteCond %{HTTP:Host} ^(?:.*)\.negozioelettronico\..*$
RewriteCond %{REQUEST_URI} ^/page\.htm$
RewriteRule .* /newpage.htm
RewriteCond %{HTTP:Host} ^(?:.*)\.negozioelettronico\..*$
RewriteCond %{HTTP_X_REWRITE_URL} ^/page\.htm$
RewriteRule .* /newpage.htm
RewriteCond %{HTTP:Host} ^(?:.*)\.negozioelettronico\..*$
RewriteCond %{URL} ^/page\.htm$
RewriteRule .* /newpage.htm
-----------
First RULE work Fine, after First RULE the variable "REQUEST_URI" remain with Original VALUE, and REQUEST_URI have same value of HTTP_X_REWRITE_URL.
(3) applying pattern '.*' to uri '/test'
(4) RewriteCond: input='srcdemo.negozioelettronico.it' pattern='^(?:.*)\.negozioelettronico\..*$' => matched
(4) RewriteCond: input='/test' pattern='^/test$' => matched
(1) Rewrite URL to >> /page.htm
(2) rewrite '/test' -> '/page.htm'
(3) applying pattern '.*' to uri '/page.htm'
(4) RewriteCond: input='srcdemo.negozioelettronico.it' pattern='^(?:.*)\.negozioelettronico\..*$' => matched
(4) RewriteCond: input='/test' pattern='^/page\.htm$' => not-matched <<<<<<<<<<<<<<<<<<<<<<<<<< should be value of "input" variable set to "page.htm" ?
May be a bug or misconfiguration ?
(3) applying pattern '.*' to uri '/page.htm'
(4) RewriteCond: input='srcdemo.negozioelettronico.it' pattern='^(?:.*)\.negozioelettronico\..*$' => matched
(4) RewriteCond: input='/test' pattern='^/page\.htm$' => not-matched
(3) applying pattern '.*' to uri '/page.htm'
(4) RewriteCond: input='srcdemo.negozioelettronico.it' pattern='^(?:.*)\.negozioelettronico\..*$' => matched
(4) RewriteCond: input='/test' pattern='^/page\.htm$' => not-matched
regards
MLM
- HeliconAndrew
-
- Posts: 1264
- Joined: 07 Mar 2012, 10:16
Re: Consecutive RewriteRule (conversion by 2.0 ver)
Tanks for this one... we need to test in our environment. What build are you using? And what is the version of your IIS?
Re: Consecutive RewriteRule (conversion by 2.0 ver)
Win Server 2012
IIS 8.0.9200.16384
Isapi Rewrite 3.1.0.99
File .htaccess with this configuration
RewriteEngine On
RewriteCompatibility2 On <<< don't work with or without this
RepeatLimit 8
RewriteBase
RewriteCond %{HTTP:Host} ^(?:.*)\.negozioelettronico\..*$
RewriteCond %{REQUEST_URI} ^/test$
RewriteRule .* /page\.htm
RewriteCond %{HTTP:Host} ^(?:.*)\.negozioelettronico\..*$
RewriteCond %{REQUEST_URI} ^/page\.htm$
RewriteRule .* /newpage.htm
thanks
regards
MLM
IIS 8.0.9200.16384
Isapi Rewrite 3.1.0.99
File .htaccess with this configuration
RewriteEngine On
RewriteCompatibility2 On <<< don't work with or without this
RepeatLimit 8
RewriteBase
RewriteCond %{HTTP:Host} ^(?:.*)\.negozioelettronico\..*$
RewriteCond %{REQUEST_URI} ^/test$
RewriteRule .* /page\.htm
RewriteCond %{HTTP:Host} ^(?:.*)\.negozioelettronico\..*$
RewriteCond %{REQUEST_URI} ^/page\.htm$
RewriteRule .* /newpage.htm
thanks
regards
MLM
- HeliconAndrew
-
- Posts: 1264
- Joined: 07 Mar 2012, 10:16
Re: Consecutive RewriteRule (conversion by 2.0 ver)
This is specifics of ISAPI_Rewrite 3, please, see http://www.helicontech.com/articles/exploding-myths-about-mod_rewrite-part-i/ and http://www.helicontech.com/articles/exploding-myths-about-mod_rewrite-part-2/ to understand the logic behind it.
Regards
Andrew
Regards
Andrew
Re: Consecutive RewriteRule (conversion by 2.0 ver)
this means that ISAPI 2 works differently from ISAPI 3?
there is not a variable that contains "rewritten REQUEST_URI" ?
there is a solution to get the same behavior of ISAPI 2 using ISAPI 3 ?
regards
MLM
there is not a variable that contains "rewritten REQUEST_URI" ?
there is a solution to get the same behavior of ISAPI 2 using ISAPI 3 ?
regards
MLM
Re: Consecutive RewriteRule (conversion by 2.0 ver)
Hello,
Please try to use the following config in ISAPI_Rewrite 3 to achieve what you want:
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} ^.*\.negozioelettronico\.
RewriteRule ^test$ /page.htm [NC]
RewriteCond %{HTTP_HOST} ^.*\.negozioelettronico\.
RewriteRule ^page\.htm$ /newpage.htm [NC]
Please try to use the following config in ISAPI_Rewrite 3 to achieve what you want:
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} ^.*\.negozioelettronico\.
RewriteRule ^test$ /page.htm [NC]
RewriteCond %{HTTP_HOST} ^.*\.negozioelettronico\.
RewriteRule ^page\.htm$ /newpage.htm [NC]
11 posts
• Page 1 of 1
Who is online
Users browsing this forum: No registered users and 16 guests