Sorry if this has been asked before, but I couldn't find it. I have a folder which when I visit loads in both HTTPS and HTTP.
对不起,如果之前有人询问,但我找不到它。我有一个文件夹,当我访问HTTPS和HTTP中的加载时。
I want all the files in that folder to load in HTTP except for one file. The file I need in in HTTPS is: login.php and this folder is called "forum". Also if it helps: All the files in the folder are *.php.
我希望该文件夹中的所有文件都在HTTP中加载,但一个文件除外。我在HTTPS中需要的文件是:login.php,这个文件夹叫做“forum”。如果它有帮助:文件夹中的所有文件都是* .php。
I was trying something along the lines of:
我正在尝试以下方面:
#RewriteCond %{SERVER_PORT} !^443$
#RewriteRule ^/login.php$ - [L]
#RewriteCond %{SERVER_PORT} ^443$
#RewriteRule ^(/login.php) $ https://%{HTTP_HOST}/$1 [QSA,NC,R,L]
#RewriteCond %{SERVER_PORT} !^443$
#RewriteRule ^(.*)$ http://%{HTTP_HOST}/$1 [QSA,NC,R,L]
I'm a bit of an amateur when it comes to mod_rewrite so forgive me if the above is completely off. Also if you post a solution I would appreciate it if you post it with an explanation so I can actually LEARN how it works.
当谈到mod_rewrite时,我有点像业余爱好,所以请原谅我,如果以上完全关闭的话。此外,如果你发布一个解决方案,我会很感激,如果你发布一个解释,所以我实际上可以了解它是如何工作的。
Thanks in advance! David
提前致谢!大卫
2 个解决方案
#1
Give this a try:
尝试一下:
Options +FollowSymLinks
RewriteEngine On
# port 443 traffic to http://, except login.php
RewriteCond %{SERVER_PORT} ^443$
RewriteCond %{REQUEST_URI} !^/login\.php$ [NC]
RewriteRule .* http://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
# port 80 traffic for login.php to https://
RewriteCond %{SERVER_PORT} ^80$
RewriteCond %{REQUEST_URI} ^/login\.php$ [NC]
RewriteRule .* https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
#2
Try these rules:
试试这些规则:
RewriteCond %{SERVER_PORT} !=443
RewriteRule ^login\.php$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
RewriteCond %{SERVER_PORT} !=80
RewriteRule !^login\.php$ http://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
#1
Give this a try:
尝试一下:
Options +FollowSymLinks
RewriteEngine On
# port 443 traffic to http://, except login.php
RewriteCond %{SERVER_PORT} ^443$
RewriteCond %{REQUEST_URI} !^/login\.php$ [NC]
RewriteRule .* http://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
# port 80 traffic for login.php to https://
RewriteCond %{SERVER_PORT} ^80$
RewriteCond %{REQUEST_URI} ^/login\.php$ [NC]
RewriteRule .* https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
#2
Try these rules:
试试这些规则:
RewriteCond %{SERVER_PORT} !=443
RewriteRule ^login\.php$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
RewriteCond %{SERVER_PORT} !=80
RewriteRule !^login\.php$ http://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]