[SlugBug] Restricting HTTP in just one directory (followup from another discussion cut short!)

Chris chris at slugbug.org.uk
Thu Jan 26 17:58:59 GMT 2006


Hi

On Thu 26-Jan-2006 at 05:53:04PM +0000, Chris wrote:
> 
> On Thu 26-Jan-2006 at 05:37:30PM +0000, James Wallbank wrote:
> 
> The Redirect should do the trick, though if you want to put this in a
> .htaccess file rather than the actual Apache config file then it's
> more complicated -- you would need to check in the env var HTTPS has
> the value "on" and if so don't redirect and it the env var doesn't
> exist then do the redirect.

Hmm, actually I think in this case you would have to use mod_rewrite,
since I don't think you can do any kind of if thing in a .htacces file.

Something *like* this:

> <Directory "/svr/www/htdocs/panel">
>         RewriteEngine on
>         Options +FollowSymLinks
>         Order allow,deny
>         Allow from all
>         RewriteCond %{SERVER_PORT} !^443$
>         RewriteRule ^.*$ https://%{SERVER_NAME}%{REQUEST_URI} [L,R]
> </Directory>

But neater than using ServerPort is to use the $HTTPS env var should do
the trick...

Chris


More information about the SlugBug mailing list