Link to home
Start Free TrialLog in
Avatar of FireBall
FireBall

asked on

htaccess question

hello friends ,

we want to use https only the in creditcard.php page and all the other pages will be redirected to the http .
and we want to let it access creditcard.php who has the cookie with name user. or it will be redirected to the 403 page


is that possible
Thank you
Avatar of Julian Matz
Julian Matz
Flag of Ireland image

Hey! Give this a try. I haven't tested it.

RewriteEngine on

RewriteCond %{HTTPS} off
RewriteRule ^creditcard\.php$ https://www.example.com/creditcard.php [L,R=301]

RewriteCond %{HTTPS} on
RewriteCond %{REQUEST_URI} !^creditcard\.php
RewriteRule ^(.*)$ http://www.example.com/$1 [L,R=301]

RewriteCond %{REQUEST_URI} !^creditcard\.php
RewriteCond %{HTTP_COOKIE} !user
RewriteRule ^(.*)$ - [R=403,L]

Open in new window

Avatar of FireBall
FireBall

ASKER

seems perfect one last question is that possible on Nginz config too?
I haven't used Nginx before, but I think the rewrite rules are very similar. Have a look here:
http://nginx.org/en/docs/http/ngx_http_rewrite_module.html#rewrite
ASKER CERTIFIED SOLUTION
Avatar of Julian Matz
Julian Matz
Flag of Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Thank you so much