简体   繁体   English

如何将全部重定向到ssl和index.php,而不是ssl,但是将所有页面重定向到特定页面上的index.php

[英]How to redirect all to ssl and to index.php but not ssl but redirect all to index.php on a specific page

I want all to force redirect to https but not on a specific page currently i have this .htaccess file: 我希望所有人都强制重定向到https,但目前不在特定页面上,我有此.htaccess文件:

RewriteEngine on
RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /index.php?path=$1 [NC,L,QSA]

I want all to redirect to https but force http on a specific page: /exchage 我希望所有人都重定向到https,但在特定页面上强制使用http:/ exchage

What code do I need to put on my .htaccess file to achieve this function? 要实现此功能,我需要在.htaccess文件中放什么代码? Thanks. 谢谢。

What about adding another condition to the HTTPS redirect to check that the path doesn't start with exchange ? 如何在HTTPS重定向中添加另一个条件以检查路径不是以exchange开头呢? (I assume you misspelled exch age ) (我认为您的年龄年龄拼写错误)

RewriteEngine on
RewriteCond %{REQUEST_URI} !^/exchange
RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
RewriteCond %{REQUEST_URI} ^/exchange
RewriteCond %{HTTPS} on
RewriteRule ^(.*)$ http://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /index.php?path=$1 [NC,L,QSA]

Once you have updated your .htaccess file, please restart your browser. 更新.htaccess文件后,请重新启动浏览器。 Otherwise it might force https if it has previously seen the URL use https. 否则,如果以前已经看到URL使用https,则可能会强制使用https。

I solve the problem with this code. 我用这段代码解决了这个问题。

RewriteEngine on
RewriteCond %{HTTPS} off
RewriteCond %{THE_REQUEST} !/exchange
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
RewriteCond %{HTTPS} on
RewriteCond %{THE_REQUEST} /exchange
RewriteRule ^ http://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /index.php?path=$1 [NC,L,QSA]

took me almost 3 hours just to come out with this code. 我花了将近3个小时才拿出这段代码。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM