This is a discussion on How to redirect all pages except one specific within the Apache Web Server forums, part of the Web Server and Related Forums category; Please I need help on this (in httpd.conf under apache) . I woulk like to redirect all pages except one . ...
|
|||||||
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
|
|||
|
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 |
|
|||
|
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 |
|
|||
|
Rik wrote:
> 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] > Thanks It works . I don't even need this line : RewriteCond %{SERVER_PROTOCOL} !^https$ [NC] nor RewriteCond %{SERVER_PROTOCOL} ^https$ [NC] |