This is a discussion on mod_rewrite Apache 2.0.48 within the Apache Web Server forums, part of the Web Server and Related Forums category; Using the following in httpd.conf: # rewrite environment RewriteEngine on RewriteLog /usr/local/apache2/logs/https_rewrite_log RewriteLogLevel 3 RewriteCond %{HTTPS} !=...
|
|||||||
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
|
|||
|
Using the following in httpd.conf:
# rewrite environment RewriteEngine on RewriteLog /usr/local/apache2/logs/https_rewrite_log RewriteLogLevel 3 RewriteCond %{HTTPS} !=on RewriteRule ^/(.*)$ https://%{SERVER_NAME}/cgi-bin/useradmin.pl [L,R] RewriteCond %{HTTPS} =on RewriteRule ^/(.*)$ https://%{SERVER_NAME}/cgi-bin/useradmin.pl [L,R] All http requests to %{SERVER_NAME} are rewritten to https and the cgi is run as expected, but all https requests just pull up the https Apache banner page and nothing else, the URL is not rewritten and the cgi script is not run. What am I missing here? Any pointers appreciated. -- Barton Fisk Replace NOSPAM with net to reply via email. --------- Using M2, Opera's revolutionary e-mail client: http://www.opera.com/m2/ |
|
|||
|
Barton Fisk wrote:
> Using the following in httpd.conf: > > # rewrite environment > RewriteEngine on > RewriteLog /usr/local/apache2/logs/https_rewrite_log > RewriteLogLevel 3 > RewriteCond %{HTTPS} !=on > RewriteRule ^/(.*)$ > https://%{SERVER_NAME}/cgi-bin/useradmin.pl [L,R] > RewriteCond %{HTTPS} =on > RewriteRule ^/(.*)$ > https://%{SERVER_NAME}/cgi-bin/useradmin.pl [L,R] > > All http requests to %{SERVER_NAME} are rewritten to https and the cgi > is run as expected, but all https requests just pull up the https Apache > banner page and nothing else, the URL is not rewritten and the cgi > script is not run. > > What am I missing here? Any pointers appreciated. > I've not messed with Apache 2 for anything as of yet, but did you try taking out the "=" in the RewriteCond statements? -- Justin Koivisto - spam@koivi.com PHP POSTERS: Please use comp.lang.php for PHP related questions, alt.php* groups are not recommended. |
|
|||
|
On Tue, 09 Dec 2003 14:00:39 GMT, Justin Koivisto <spam@koivi.com> wrote:
> Barton Fisk wrote: >> Using the following in httpd.conf: >> >> # rewrite environment >> RewriteEngine on >> RewriteLog /usr/local/apache2/logs/https_rewrite_log >> RewriteLogLevel 3 >> RewriteCond %{HTTPS} !=on >> RewriteRule ^/(.*)$ >> https://%{SERVER_NAME}/cgi-bin/useradmin.pl [L,R] >> RewriteCond %{HTTPS} =on >> RewriteRule ^/(.*)$ >> https://%{SERVER_NAME}/cgi-bin/useradmin.pl [L,R] >> >> All http requests to %{SERVER_NAME} are rewritten to https and the cgi >> is run as expected, but all https requests just pull up the https >> Apache banner page and nothing else, the URL is not rewritten and the >> cgi script is not run. >> >> What am I missing here? Any pointers appreciated. >> > > I've not messed with Apache 2 for anything as of yet, but did you try > taking out the "=" in the RewriteCond statements? > Justin, I just took the = out and restarted. Didn't make any difference. I'm open for suggestions. -- Barton Fisk Replace NOSPAM with net to reply via email. --------- Using M2, Opera's revolutionary e-mail client: http://www.opera.com/m2/ |
|
|||
|
Barton Fisk wrote:
> On Tue, 09 Dec 2003 14:00:39 GMT, Justin Koivisto <spam@koivi.com> wrote: > >> Barton Fisk wrote: >> >>> Using the following in httpd.conf: >>> >>> # rewrite environment >>> RewriteEngine on >>> RewriteLog /usr/local/apache2/logs/https_rewrite_log >>> RewriteLogLevel 3 >>> RewriteCond %{HTTPS} !=on >>> RewriteRule ^/(.*)$ >>> https://%{SERVER_NAME}/cgi-bin/useradmin.pl [L,R] >>> RewriteCond %{HTTPS} =on >>> RewriteRule ^/(.*)$ >>> https://%{SERVER_NAME}/cgi-bin/useradmin.pl [L,R] >>> >>> All http requests to %{SERVER_NAME} are rewritten to https and the >>> cgi is run as expected, but all https requests just pull up the https >>> Apache banner page and nothing else, the URL is not rewritten and the >>> cgi script is not run. >>> >>> What am I missing here? Any pointers appreciated. >>> >> >> I've not messed with Apache 2 for anything as of yet, but did you try >> taking out the "=" in the RewriteCond statements? >> > > Justin, I just took the = out and restarted. Didn't make any difference. > > I'm open for suggestions. For Apache 1.3, %{HTTPS} is only defined if the request is for an https:// address. I don't know if the same holds true for 2.0, but maybe try something like: ------ RewriteCond %{HTTPS} !on RewriteRule ^/(.*)$ https://%{SERVER_NAME}/cgi-bin/useradmin.pl [L,R] RewriteRule ^/(.*)$ https://%{SERVER_NAME}/cgi-bin/useradmin.pl [L,R] ------ Since you are using the L flag, the second rule should only be used if HTTPS is !on. However, since your rule is the same either way, I don't think that the RewriteCond is even necessary. -- Justin Koivisto - spam@koivi.com PHP POSTERS: Please use comp.lang.php for PHP related questions, alt.php* groups are not recommended. |
|
|||
|
On Tue, 09 Dec 2003 15:41:59 GMT, Justin Koivisto <spam@koivi.com> wrote:
> Barton Fisk wrote: > >> On Tue, 09 Dec 2003 14:00:39 GMT, Justin Koivisto <spam@koivi.com> >> wrote: >> >>> Barton Fisk wrote: >>> >>>> Using the following in httpd.conf: >>>> >>>> # rewrite environment >>>> RewriteEngine on >>>> RewriteLog /usr/local/apache2/logs/https_rewrite_log >>>> RewriteLogLevel 3 >>>> RewriteCond %{HTTPS} !=on >>>> RewriteRule ^/(.*)$ >>>> https://%{SERVER_NAME}/cgi-bin/useradmin.pl [L,R] >>>> RewriteCond %{HTTPS} =on >>>> RewriteRule ^/(.*)$ >>>> https://%{SERVER_NAME}/cgi-bin/useradmin.pl [L,R] >>>> >>>> All http requests to %{SERVER_NAME} are rewritten to https and the >>>> cgi is run as expected, but all https requests just pull up the https >>>> Apache banner page and nothing else, the URL is not rewritten and the >>>> cgi script is not run. >>>> >>>> What am I missing here? Any pointers appreciated. >>>> >>> >>> I've not messed with Apache 2 for anything as of yet, but did you try >>> taking out the "=" in the RewriteCond statements? >>> >> >> Justin, I just took the = out and restarted. Didn't make any difference. >> >> I'm open for suggestions. > > For Apache 1.3, %{HTTPS} is only defined if the request is for an > https:// address. I don't know if the same holds true for 2.0, but maybe > try something like: > > ------ > RewriteCond %{HTTPS} !on > RewriteRule ^/(.*)$ https://%{SERVER_NAME}/cgi-bin/useradmin.pl [L,R] > > RewriteRule ^/(.*)$ https://%{SERVER_NAME}/cgi-bin/useradmin.pl [L,R] > ------ > > Since you are using the L flag, the second rule should only be used if > HTTPS is !on. However, since your rule is the same either way, I don't > think that the RewriteCond is even necessary. > Tried this, same behavior, then I commented out the RewriteCond and first RewriteRule line and tried again, same behavior. When I hit the https:// URL there is nothing in the rewrite logs so it looks like the flaw might be in my pattern expression? Doesn't the ^/(.*)$ expression match the entire line, no matter what? I'm grasping for straws here. Unless I found a bug perhaps? Your right, the RewriteCond is not needed anyhow. The http->https rewrite is working without it. -- Barton Fisk Replace NOSPAM with net to reply via email. --------- Using M2, Opera's revolutionary e-mail client: http://www.opera.com/m2/ |
|
|||
|
Barton Fisk wrote:
> On Tue, 09 Dec 2003 15:41:59 GMT, Justin Koivisto <spam@koivi.com> wrote: > >> Barton Fisk wrote: >> >>> On Tue, 09 Dec 2003 14:00:39 GMT, Justin Koivisto <spam@koivi.com> >>> wrote: >>> >>>> Barton Fisk wrote: >>>> >>>>> Using the following in httpd.conf: >>>>> >>>>> # rewrite environment >>>>> RewriteEngine on >>>>> RewriteLog /usr/local/apache2/logs/https_rewrite_log >>>>> RewriteLogLevel 3 >>>>> RewriteCond %{HTTPS} !=on >>>>> RewriteRule ^/(.*)$ >>>>> https://%{SERVER_NAME}/cgi-bin/useradmin.pl [L,R] >>>>> RewriteCond %{HTTPS} =on >>>>> RewriteRule ^/(.*)$ >>>>> https://%{SERVER_NAME}/cgi-bin/useradmin.pl [L,R] >>>>> >>>>> All http requests to %{SERVER_NAME} are rewritten to https and the >>>>> cgi is run as expected, but all https requests just pull up the >>>>> https Apache banner page and nothing else, the URL is not rewritten >>>>> and the cgi script is not run. >>>>> >>>>> What am I missing here? Any pointers appreciated. >>>>> >>>> >>>> I've not messed with Apache 2 for anything as of yet, but did you >>>> try taking out the "=" in the RewriteCond statements? >>>> >>> >>> Justin, I just took the = out and restarted. Didn't make any difference. >>> >>> I'm open for suggestions. >> >> >> For Apache 1.3, %{HTTPS} is only defined if the request is for an >> https:// address. I don't know if the same holds true for 2.0, but >> maybe try something like: >> >> ------ >> RewriteCond %{HTTPS} !on >> RewriteRule ^/(.*)$ https://%{SERVER_NAME}/cgi-bin/useradmin.pl [L,R] >> >> RewriteRule ^/(.*)$ https://%{SERVER_NAME}/cgi-bin/useradmin.pl [L,R] >> ------ >> >> Since you are using the L flag, the second rule should only be used if >> HTTPS is !on. However, since your rule is the same either way, I don't >> think that the RewriteCond is even necessary. >> > > Tried this, same behavior, then I commented out the RewriteCond and > first RewriteRule line and tried again, same behavior. > > When I hit the https:// URL there is nothing in the rewrite logs so it > looks like the flaw might be in my pattern expression? Doesn't the > ^/(.*)$ expression match the entire line, no matter what? I'm grasping > for straws here. Unless I found a bug perhaps? DOH! I totally missed that... RewriteRule ^(.*)$ https://%{SERVER_NAME}/cgi-bin/useradmin.pl [L,R] The leading slash is automatically stripped, so your pattern isn't matching anything, and that is why it's happening. -- Justin Koivisto - spam@koivi.com PHP POSTERS: Please use comp.lang.php for PHP related questions, alt.php* groups are not recommended. |
|
|||
|
Barton Fisk wrote:
> On Tue, 09 Dec 2003 15:41:59 GMT, Justin Koivisto <spam@koivi.com> wrote: > >> Barton Fisk wrote: >> >>> On Tue, 09 Dec 2003 14:00:39 GMT, Justin Koivisto <spam@koivi.com> >>> wrote: >>> >>>> Barton Fisk wrote: >>>> >>>>> Using the following in httpd.conf: >>>>> >>>>> # rewrite environment >>>>> RewriteEngine on >>>>> RewriteLog /usr/local/apache2/logs/https_rewrite_log >>>>> RewriteLogLevel 3 >>>>> RewriteCond %{HTTPS} !=on >>>>> RewriteRule ^/(.*)$ >>>>> https://%{SERVER_NAME}/cgi-bin/useradmin.pl [L,R] >>>>> RewriteCond %{HTTPS} =on >>>>> RewriteRule ^/(.*)$ >>>>> https://%{SERVER_NAME}/cgi-bin/useradmin.pl [L,R] >>>>> >>>>> All http requests to %{SERVER_NAME} are rewritten to https and the >>>>> cgi is run as expected, but all https requests just pull up the >>>>> https Apache banner page and nothing else, the URL is not rewritten >>>>> and the cgi script is not run. >>>>> >>>>> What am I missing here? Any pointers appreciated. >>>>> >>>> >>>> I've not messed with Apache 2 for anything as of yet, but did you >>>> try taking out the "=" in the RewriteCond statements? >>>> >>> >>> Justin, I just took the = out and restarted. Didn't make any difference. >>> >>> I'm open for suggestions. >> >> >> For Apache 1.3, %{HTTPS} is only defined if the request is for an >> https:// address. I don't know if the same holds true for 2.0, but >> maybe try something like: >> >> ------ >> RewriteCond %{HTTPS} !on >> RewriteRule ^/(.*)$ https://%{SERVER_NAME}/cgi-bin/useradmin.pl [L,R] >> >> RewriteRule ^/(.*)$ https://%{SERVER_NAME}/cgi-bin/useradmin.pl [L,R] >> ------ >> >> Since you are using the L flag, the second rule should only be used if >> HTTPS is !on. However, since your rule is the same either way, I don't >> think that the RewriteCond is even necessary. >> > > Tried this, same behavior, then I commented out the RewriteCond and > first RewriteRule line and tried again, same behavior. > > When I hit the https:// URL there is nothing in the rewrite logs so it > looks like the flaw might be in my pattern expression? Doesn't the > ^/(.*)$ expression match the entire line, no matter what? I'm grasping > for straws here. Unless I found a bug perhaps? DOH! I totally missed that... RewriteRule ^(.*)$ https://%{SERVER_NAME}/cgi-bin/useradmin.pl [L,R] -- Justin Koivisto - spam@koivi.com PHP POSTERS: Please use comp.lang.php for PHP related questions, alt.php* groups are not recommended. |
| Thread Tools | |
| Display Modes | |
|
|