mod_rewrite Apache 2.0.48

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} !=...


Go Back   Usenet Forums > Web Server and Related Forums > Apache Web Server

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 12-09-2003
Barton Fisk
 
Posts: n/a
Default mod_rewrite Apache 2.0.48

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/
  #2 (permalink)  
Old 12-09-2003
Justin Koivisto
 
Posts: n/a
Default Re: mod_rewrite Apache 2.0.48

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.

  #3 (permalink)  
Old 12-09-2003
Barton Fisk
 
Posts: n/a
Default Re: mod_rewrite Apache 2.0.48

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/
  #4 (permalink)  
Old 12-09-2003
Justin Koivisto
 
Posts: n/a
Default Re: mod_rewrite Apache 2.0.48

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.

  #5 (permalink)  
Old 12-09-2003
Barton Fisk
 
Posts: n/a
Default Re: mod_rewrite Apache 2.0.48

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/
  #6 (permalink)  
Old 12-09-2003
Justin Koivisto
 
Posts: n/a
Default Re: mod_rewrite Apache 2.0.48

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.

  #7 (permalink)  
Old 12-09-2003
Justin Koivisto
 
Posts: n/a
Default Re: mod_rewrite Apache 2.0.48

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

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT +1. The time now is 02:56 PM.


Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0