Forum Moderators: phranque

Message Too Old, No Replies

mod_rewrite works once

Basic mod_rewrite problem

         

lsdodd

2:14 pm on Feb 23, 2004 (gmt 0)

10+ Year Member



Hi all

I'm having a problem with mod_rewrite, it works the first time I start the apache (2.0.48) server (sometimes) but revists do not work.
As a basic test, I've setup secure dir with a simple index.html file (says it's a secure web page).
Using IE6 and [example.com...] gives a forbidden screen, which is what I want.
Using https, I may see the secure screen but most of the time I keep seeing forbidden screen.
There's been about 1in10 chances on seeing the secure screen and thats been when the server has been restarted.

Config can from the mod_ssl site

<Directory /usr/local/apache/htdocs/secure>
AllowOverride all
RewriteEngine on
RewriteCond %{HTTPS}!=on
RewriteRule .* - [F]
</Directory>

I built the server using
./configure --prefix=/usr/local/apache --enable-ssl --with-ssl=/usr/local/ssl --enable-so --enable-rewrite=shared

And loading the module as follows.
LoadModule php4_module modules/libphp4.so
LoadModule rewrite_module modules/mod_rewrite.so

If I comment out the Rewrite's then the secure page gets displayed using http and/or https, which is what you'd expect (shows that SSL is working OK)

Any mod_rewite debug switches I can turn on since a apache Debug LogLevel does not give any clues?

Thanks in advance

Leigh

jdMorgan

3:29 pm on Feb 23, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Leigh,

Welcome to WebmasterWorld [webmasterworld.com]!

I have never seen this construct used before (although that's not saying much):

 RewriteCond %{HTTPS} !=on 

Specifically, are you sure that "{HTTPS}" is a valid server environment variable?

I've seen

 RewriteCond %{SERVER_PROTOCOL} ^HTTP/1\.0$ 

-and-
 RewriteCond %{THE_REQUEST} ^GET\ .*\ HTTP/1\.1 

used in some working code. These are both request-based, rather than configuration-based, and so may be more useful to determine whether the *current* request is being made via HTTPS, rather than whether HTTPS is enabled on the server.

I'll confess that the above is just a guess, and the only useful part of this post may be the "Welcome" line... :)

Jim

lsdodd

3:51 pm on Feb 23, 2004 (gmt 0)

10+ Year Member



Hi Jim

Got the Rewrite from

[httpd.apache.org...]
(near the bottom)

Leigh

jdMorgan

5:10 pm on Feb 23, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Hmmm... Well, ya learn something every day... Good reference.

Another member is reporting intermittent redirect problems, and I'm wondering if this could be a simple stale-cache issue: [webmasterworld.com...]

The cache-control header for secure pages may need to be set for no-cache or must-revalidate with a short expiry time in order to work properly using redirects.

Jim