Why is it not working?

why is this not working??

RewriteEngine On

RewriteCond %{HTTPS}        =off   [OR]
RewriteCond %{HTTP_HOST}   !^www\. [OR]
RewriteCond %{THE_REQUEST}  ^[A-Z]{3,9}\ /index\.(html|php)
RewriteCond %{QUERY_STRING} ^route=(account/register|account/login|account/account|checkout/checkout)
RewriteCond %{HTTP_HOST}    ^(www\.)?(.+)$
RewriteRule ^(index\.(html|php))|(.*)$ https://www.%2/$3 [R=301,L]

you need extactly redirect to https as it was at http ?

i am not sure if i understand you?

freshy,

Comments:

{HTTPS} is either on or null

The set of RewriteCond statements are ANDed after the first pair or OR’s. so, if one of the first three is matched AND #4 is matched AND #5 is matched, THEN the RewriteRule is executed (actually, it’s first but, logically speaking …) and your EVERYTHING atom then captures EVERYTHING (or nothing) so your redirection is executed (without changing the query strong). Note that EVERYTHING includes all files whether .php, html, js, jpg, gif, css, yadda yadda.

[standard rant #1][indent]The use of “lazy regex,” specifically the EVERYTHING atom, (.*), and its close relatives, is the NUMBER ONE coding error of newbies BECAUSE it is “greedy.” Unless you provide an “exit” from your redirection, you will ALWAYS end up in a loop![/indent][/standard rant #1]

Now that I’ve gotten that rant out of my system, it is possible that RewriteCond #3 will cause $1 to be matched so that, as far as a URL is concerned, $3 can’t exist.

What you’ve shown is very confusing so, would you please describe what you’re trying to do?

Regards,

DK

{HTTPS} is either “on” or “off”. Pretty sure I’ve mentioned this to you before.

http://httpd.apache.org/docs/2.4/mod/mod_rewrite.html#rewritecond

OMG?!? After many years of null or on, it appears that {HTTPS} has been updated in Apache 2.4 [prior versions were not likely updated].

HOWEVER, historically, {HTTPS} was either null or on which led to the preferred use of the {SERVER_PORT} variable to test for either port 80 or port 443. Thus, unless you can confirm Apache 2.4, use the {SERVER_PORT} variable in your RewriteCond.

Regards,

It’s been that way for every 2.x release.

http://httpd.apache.org/docs/2.0/mod/mod_rewrite.html#rewritecond

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.