Web Servers on Unix and Linux - negate a regex

This is Interesting: Free IT Magazines  
Home > Archive > Web Servers on Unix and Linux > January 2006 > negate a regex





You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

Author negate a regex
maxim2k

2006-01-18, 5:52 pm

Hi all,

I have a web site with a directory that needs to be accessed only over
HTTPS, HTTP access shouldn't be allowed to that directory for security
reasons.

The rest of the web site needs to be accessed only over HTTP, HTTPS
access shouldn't be allowed to the rest of the web site for
performance reasons.

The document root between the HTTP and HTTPS Apache virtual hosts is shared.

I have the following directive in my Apache HTTP vhost config file to
make sure that if anyone tries to access the secure directory over
HTTP, he is redirected to the HTTPS URL:

RedirectPermanent ^/secureDirectory/
https://www.mywebsite.com/secureDirectory/

This directive works just fine.

Now I need a directive for the Apache HTTPS vhost config file to make
sure that if anyone tries to access the rest of the web site (anything
outside the secure directory) over HTTPS, he is redirected to the HTTP
URL, something like this:

RedirectPermanent !^/secureDirectory/ http://www.mywebsite.com/

Obviously this directive doesn't work, since that's not the right way
to negate a regular expression.
How do I negate it?

Do you have a better solution for this?

Thanks.
Sponsored Links






Free braindumps | Software forum | Database administration forum

Copyright 2003 - 2008 webservertalk.com