开发者

Is it possible to have a certain files in a server to redirect to https and others are forced to only http no matter if you put https

Is it possible to do this on .htaccess

if(filename.php = "order.php"){
  redirect to https
}else{
  redirect to http
}

I need it to do something like this, user might want to put https on my index.php and its unsecure and gives an error, that wh开发者_开发百科y I need to force to http if its not order.php, and force https if its order.php

I have 3 similar folders like in 1 server,

I tried to use this

RewriteEngine On
RewriteRule /(order.php) https://%{SERVER_NAME}%{REQUEST_URI} [L]

but failed, I did it on PHP, but I will have to put all of it hundred files.

So Iguess .htaccess will be more time efficient,


Yes it's possible

RewriteEngine on
RewriteCond %{HTTPS} off
RewriteCond %{REQUEST_URI}  ^/order.php
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

RewriteCond %{HTTPS} on
RewriteCond %{REQUEST_URI}  !^/order.php
RewriteRule (.*) http://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜