Rewrite working/not working in different versions
4 posts
• Page 1 of 1
- duncancumming
- Posts: 3
- Joined: 11 May 2012, 05:40
Rewrite working/not working in different versions
In version 3.1.0.61, this works. I want to redirect anyone on a domain like secure-blah to http://blah for all requests apart from those for the /checkout/ and /confirmation/ and /assets/ folders. e.g. if you're on http://secure-blah.example.com/foobar/ I want to redirect you to http://blah.example.com/foobar/
This doesn't seem to work on other computers that have more recent versions. For instance I know it doesn't work on 3.1.0.82.
I don't want to use the %{HTTPS} directive to do this, as basically people can access our secure-blah domains on both http and https. So trying to do it all just by looking at the REQUEST_URI.
Is there a flaw in the regex? Or some kind of bug in either v 3.1.0.61 that allows this to work, or v 3.1.0.82 that doesn't allow it?
- Code: Select all
RewriteCond %{HTTP:Host} secure-(.*)
RewriteCond %{REQUEST_URI} ^(?!/(?:checkout|confirmation|assets))(.*)$
RewriteRule .? http://%1%2 [R=301,L]
This doesn't seem to work on other computers that have more recent versions. For instance I know it doesn't work on 3.1.0.82.
I don't want to use the %{HTTPS} directive to do this, as basically people can access our secure-blah domains on both http and https. So trying to do it all just by looking at the REQUEST_URI.
Is there a flaw in the regex? Or some kind of bug in either v 3.1.0.61 that allows this to work, or v 3.1.0.82 that doesn't allow it?
- HeliconAndrew
- Posts: 1264
- Joined: 07 Mar 2012, 10:16
- duncancumming
- Posts: 3
- Joined: 11 May 2012, 05:40
Re: Rewrite working/not working in different versions
So for instance here's the log showing it working on my machine:
192.168.8.1 192.168.8.1 Fri, 11-May-2012 10:57:46 GMT [secure-m.example.com/sid#782794918][rid#19932256/initial] (2) init rewrite engine with requested uri /privacy/
192.168.8.1 192.168.8.1 Fri, 11-May-2012 10:57:46 GMT [secure-m.example.com/sid#782794918][rid#19932256/initial] (1) Htaccess process request C:\Apps\ISAPI_Rewrite3\httpd.conf
192.168.8.1 192.168.8.1 Fri, 11-May-2012 10:57:46 GMT [secure-m.example.com/sid#782794918][rid#19932256/initial] (1) Htaccess process request c:\websites\examplesite\www\.htaccess
192.168.8.1 192.168.8.1 Fri, 11-May-2012 10:57:46 GMT [secure-m.example.com/sid#782794918][rid#19932256/initial] (3) applying pattern '.?' to uri 'privacy/'
192.168.8.1 192.168.8.1 Fri, 11-May-2012 10:57:46 GMT [secure-m.example.com/sid#782794918][rid#19932256/initial] (4) RewriteCond: input='secure-m.example.com' pattern='secure-(.*)' => matched
192.168.8.1 192.168.8.1 Fri, 11-May-2012 10:57:46 GMT [secure-m.example.com/sid#782794918][rid#19932256/initial] (4) RewriteCond: input='/privacy/' pattern='^(?!/(?:checkout|confirmation|assets))(.*)$' => matched
192.168.8.1 192.168.8.1 Fri, 11-May-2012 10:57:46 GMT [secure-m.example.com/sid#782794918][rid#19932256/initial] (1) escaping http://m.example.com/privacy/
192.168.8.1 192.168.8.1 Fri, 11-May-2012 10:57:46 GMT [secure-m.example.com/sid#782794918][rid#19932256/initial] (2) explicitly forcing redirect with http://m.example.com/privacy/
192.168.8.1 192.168.8.1 Fri, 11-May-2012 10:57:46 GMT [secure-m.example.com/sid#782794918][rid#19932256/initial] (2) internal redirect with /privacy/ [INTERNAL REDIRECT]
And here's a log from another machine where it isn't working. In this case, the user isn't trying the secure-m domain, just going direct to m.example.com. It's as if it's ignoring the first RewriteCond against the %{HTTP:Host}
127.0.0.1 127.0.0.1 Fri, 11-May-2012 11:06:09 GMT [m.example.com/sid#49][rid#15307080/initial] (2) init rewrite engine with requested uri /
127.0.0.1 127.0.0.1 Fri, 11-May-2012 11:06:09 GMT [m.example.com/sid#49][rid#15307080/initial] (1) Htaccess process request c:\apps\ISAPI_Rewrite3\httpd.conf
127.0.0.1 127.0.0.1 Fri, 11-May-2012 11:06:09 GMT [m.example.com/sid#49][rid#15307080/initial] (1) Htaccess process request d:\websites\examplesite\www\.htaccess
127.0.0.1 127.0.0.1 Fri, 11-May-2012 11:06:09 GMT [m.example.com/sid#49][rid#15307080/initial] (3) applying pattern '.?' to uri ''
127.0.0.1 127.0.0.1 Fri, 11-May-2012 11:06:09 GMT [m.example.com/sid#49][rid#15307080/initial] (4) RewriteCond: input='/' pattern='^(?!/(?:checkout|confirmation|assets))(.*)$' => matched
127.0.0.1 127.0.0.1 Fri, 11-May-2012 11:06:09 GMT [m.example.com/sid#49][rid#15307080/initial] (1) escaping http:///
127.0.0.1 127.0.0.1 Fri, 11-May-2012 11:06:09 GMT [m.example.com/sid#49][rid#15307080/initial] (2) explicitly forcing redirect with http:///
127.0.0.1 127.0.0.1 Fri, 11-May-2012 11:06:09 GMT [m.example.com/sid#49][rid#15307080/initial] (2) internal redirect with / [INTERNAL REDIRECT]
User ends up on a page saying something like 'The document has moved'. It includes a link that goes to http:/// (notice the 3rd / )
192.168.8.1 192.168.8.1 Fri, 11-May-2012 10:57:46 GMT [secure-m.example.com/sid#782794918][rid#19932256/initial] (2) init rewrite engine with requested uri /privacy/
192.168.8.1 192.168.8.1 Fri, 11-May-2012 10:57:46 GMT [secure-m.example.com/sid#782794918][rid#19932256/initial] (1) Htaccess process request C:\Apps\ISAPI_Rewrite3\httpd.conf
192.168.8.1 192.168.8.1 Fri, 11-May-2012 10:57:46 GMT [secure-m.example.com/sid#782794918][rid#19932256/initial] (1) Htaccess process request c:\websites\examplesite\www\.htaccess
192.168.8.1 192.168.8.1 Fri, 11-May-2012 10:57:46 GMT [secure-m.example.com/sid#782794918][rid#19932256/initial] (3) applying pattern '.?' to uri 'privacy/'
192.168.8.1 192.168.8.1 Fri, 11-May-2012 10:57:46 GMT [secure-m.example.com/sid#782794918][rid#19932256/initial] (4) RewriteCond: input='secure-m.example.com' pattern='secure-(.*)' => matched
192.168.8.1 192.168.8.1 Fri, 11-May-2012 10:57:46 GMT [secure-m.example.com/sid#782794918][rid#19932256/initial] (4) RewriteCond: input='/privacy/' pattern='^(?!/(?:checkout|confirmation|assets))(.*)$' => matched
192.168.8.1 192.168.8.1 Fri, 11-May-2012 10:57:46 GMT [secure-m.example.com/sid#782794918][rid#19932256/initial] (1) escaping http://m.example.com/privacy/
192.168.8.1 192.168.8.1 Fri, 11-May-2012 10:57:46 GMT [secure-m.example.com/sid#782794918][rid#19932256/initial] (2) explicitly forcing redirect with http://m.example.com/privacy/
192.168.8.1 192.168.8.1 Fri, 11-May-2012 10:57:46 GMT [secure-m.example.com/sid#782794918][rid#19932256/initial] (2) internal redirect with /privacy/ [INTERNAL REDIRECT]
And here's a log from another machine where it isn't working. In this case, the user isn't trying the secure-m domain, just going direct to m.example.com. It's as if it's ignoring the first RewriteCond against the %{HTTP:Host}
127.0.0.1 127.0.0.1 Fri, 11-May-2012 11:06:09 GMT [m.example.com/sid#49][rid#15307080/initial] (2) init rewrite engine with requested uri /
127.0.0.1 127.0.0.1 Fri, 11-May-2012 11:06:09 GMT [m.example.com/sid#49][rid#15307080/initial] (1) Htaccess process request c:\apps\ISAPI_Rewrite3\httpd.conf
127.0.0.1 127.0.0.1 Fri, 11-May-2012 11:06:09 GMT [m.example.com/sid#49][rid#15307080/initial] (1) Htaccess process request d:\websites\examplesite\www\.htaccess
127.0.0.1 127.0.0.1 Fri, 11-May-2012 11:06:09 GMT [m.example.com/sid#49][rid#15307080/initial] (3) applying pattern '.?' to uri ''
127.0.0.1 127.0.0.1 Fri, 11-May-2012 11:06:09 GMT [m.example.com/sid#49][rid#15307080/initial] (4) RewriteCond: input='/' pattern='^(?!/(?:checkout|confirmation|assets))(.*)$' => matched
127.0.0.1 127.0.0.1 Fri, 11-May-2012 11:06:09 GMT [m.example.com/sid#49][rid#15307080/initial] (1) escaping http:///
127.0.0.1 127.0.0.1 Fri, 11-May-2012 11:06:09 GMT [m.example.com/sid#49][rid#15307080/initial] (2) explicitly forcing redirect with http:///
127.0.0.1 127.0.0.1 Fri, 11-May-2012 11:06:09 GMT [m.example.com/sid#49][rid#15307080/initial] (2) internal redirect with / [INTERNAL REDIRECT]
User ends up on a page saying something like 'The document has moved'. It includes a link that goes to http:/// (notice the 3rd / )
- duncancumming
- Posts: 3
- Joined: 11 May 2012, 05:40
Re: Rewrite working/not working in different versions
ok, we found the error. We had a comment on the same line as the first RewriteCond:
RewriteCond %{HTTP:Host} secure-(.*) # eg secure-m, secure-es-m
Taking the comment out fixed the problem!
RewriteCond %{HTTP:Host} secure-(.*) # eg secure-m, secure-es-m
Taking the comment out fixed the problem!
4 posts
• Page 1 of 1
Who is online
Users browsing this forum: No registered users and 0 guests