httpd-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Ted Fines" <ted.fi...@beta.macalester.edu>
Subject Re: [users@httpd] How to rewrite specific URL to use https
Date Thu, 19 Jul 2007 15:10:57 GMT
Hi,

Thank you.  The lines:
RewriteMap  lowercase int:tolower
RewriteRule (.*) ${lowercase:$1} [PT]

are in there because without them, we have a case-sensitive URL problem.
The new ones I'm trying to add are these:
RewriteCond %{SERVER_PORT} !^443$
RewriteCond %{REQUEST_URI} ^/restricted(.*)$ [NC]
RewriteRule ^/restricted(.*)$ https://%{SERVER_NAME}%{REQUEST_URI} [R,NC]

I'm apparently having trouble having these work together well.  When I
remove the lowercase lines, the three that do the https redirect work.  When
I remove the https redirect lines, the lowercase ones work.  Together, its
broken.

Can you clarify "add [L] to the flags on your redirect"?   Do you mean the
one that does lowercase, or the https one?

I tried:
RewriteEngine on
RewriteLogLevel 0
RewriteLog "/usr/local/apache/logs/server.mac.edu.rewrite.log"
RewriteMap  lowercase int:tolower
RewriteCond $1 [A-Z]
RewriteRule (.*) ${lowercase:$1} [PT]
RewriteCond %{SERVER_PORT} !^443$
RewriteCond %{REQUEST_URI} ^/restricted(.*)$ [NC]
RewriteRule ^/restricted(.*)$ https://%{SERVER_NAME}%{REQUEST_URI} [NC]

And this seems to work.  It correctly rewrites URLs to lowercase, and now
all reqs to /restricted get rewritten as https.

I do not understand why this doesn't work when "RewriteCond $1 [A-Z]" is
removed.  If you can clarify that, great, but the problem appears to be
solved now, thank you!

Ted

On 7/18/07, Joshua Slive <joshua@slive.ca> wrote:
>
> On 7/18/07, Ted Fines <ted.fines@beta.macalester.edu> wrote:
>
> >  RewriteLog
> > "/usr/local/apache/logs/server.mac.edu.rewrite.log"
> > RewriteCond %{SERVER_PORT} !^443$
> >  RewriteCond %{REQUEST_URI} ^/restricted(.*)$ [NC]
> >  RewriteRule ^/restricted(.*)$
> > https://%{SERVER_NAME}%{REQUEST_URI} [R,NC]
> >  RewriteMap  lowercase int:tolower
> >  RewriteRule (.*) ${lowercase:$1} [PT]
> >  </VirtualHost>
> >
> > Then in the mod_rewrite log, I see messages like:
> > rewrite /restricted/ ->
> > https://server.macalester.edu/restricted/
> > (ok, good)
> >
> > But then I see
> >  rewrite https://server.macalester.edu/restricted/ ->
> > https://server.macalester.edu/restricted/
>
> Isn't that just hitting the lowercase map?
>
> If so, you can either add [L] to the flags on your redirect, or you
> can test whether the lowercase is really necessary with a
> RewriteCond $1 [A-Z]
>
> Joshua.
>
> ---------------------------------------------------------------------
> The official User-To-User support forum of the Apache HTTP Server Project.
> See <URL: http://httpd.apache.org/userslist.html> for more info.
> To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
>    "   from the digest: users-digest-unsubscribe@httpd.apache.org
> For additional commands, e-mail: users-help@httpd.apache.org
>
>

Mime
View raw message