Apache Server configuration support - How to redirect all pages except one specific

This is Interesting: Free IT Magazines  
Home > Archive > Apache Server configuration support > August 2006 > How to redirect all pages except one specific





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 How to redirect all pages except one specific
Jack Salis

2006-08-18, 7:24 pm

Please I need help on this (in httpd.conf under apache) .
I woulk like to redirect all pages except one .
I have one domaine with two ports (80 for http and 443 for https).
One page in http is redirected to https with commande below:
Redirect /reversation.php https://www.mydomaine.com/reservation.php
And then in https , all pages should be redirected back to http except
reservation.php .
How can I do that ????????????????
I tried with examples below but didn't work

RedirectMatch ^[^reservation\.php]$ http://www.mydomaine.com/$1
or
RedirectMatch ^([^reservation\.php])$ http://www.mydomaine.com/$1


Thanks

Rik

2006-08-18, 7:24 pm

Jack Salis wrote:
> Please I need help on this (in httpd.conf under apache) .
> I woulk like to redirect all pages except one .
> I have one domaine with two ports (80 for http and 443 for https).
> One page in http is redirected to https with commande below:
> Redirect /reversation.php https://www.mydomaine.com/reservation.php
> And then in https , all pages should be redirected back to http

except
> reservation.php .
> How can I do that ????????????????
> I tried with examples below but didn't work
>
> RedirectMatch ^[^reservation\.php]$ http://www.mydomaine.com/$1
> or
> RedirectMatch ^([^reservation\.php])$ http://www.mydomaine.com/$1


The [] indicate a character class, not a literal. In this case:
^([^reservation\.php])$
means:
if the total requests consists of characters that are all not r,
e, s, v, a, t, i, o, n, ., p or h, then redirect. Idoubt this is a
scenario that will ever happen.


I've never tried this with HTTPS, but this might work. If you have
further rewriterules, put them below these ones:

RewriteCond %{SERVER_PROTOCOL} !^https$ [NC]
RewriteCond %{REQUEST_URI} ^/reservations\.php
RewriteRule ^.*$ https://example.com/$1 [R=301,L]

RewriteCond %{SERVER_PROTOCOL} ^https$ [NC]
RewriteCond %{REQUEST_URI} !^/reservations\.php
RewriteRule ^.*$ http://example.com/$1 [R=301,L]

--
Grtz,

Rik Wasmus


Jack Salis

2006-08-21, 1:43 pm

Rik wrote:

> Jack Salis wrote:
> except
>
> The [] indicate a character class, not a literal. In this case:
> ^([^reservation\.php])$
> means:
> if the total requests consists of characters that are all not r,
> e, s, v, a, t, i, o, n, ., p or h, then redirect. Idoubt this is a
> scenario that will ever happen.
>
>
> I've never tried this with HTTPS, but this might work. If you have
> further rewriterules, put them below these ones:
>
> RewriteCond %{SERVER_PROTOCOL} !^https$ [NC]
> RewriteCond %{REQUEST_URI} ^/reservations\.php
> RewriteRule ^.*$ https://example.com/$1 [R=301,L]
>
> RewriteCond %{SERVER_PROTOCOL} ^https$ [NC]
> RewriteCond %{REQUEST_URI} !^/reservations\.php
> RewriteRule ^.*$ http://example.com/$1 [R=301,L]
>


Thanks
It works .
I don't even need this line :
RewriteCond %{SERVER_PROTOCOL} !^https$ [NC]
nor
RewriteCond %{SERVER_PROTOCOL} ^https$ [NC]
Sponsored Links






Free braindumps | Software forum | Database administration forum

Copyright 2003 - 2008 webservertalk.com