Mod_Rewrite 对除一个文件之外的所有文件强制使用 HTTP
抱歉,如果之前有人问过这个问题,但我找不到。 我有一个文件夹,当我访问该文件夹时,它会同时以 HTTPS 和 HTTP 方式加载。
我希望该文件夹中除一个文件之外的所有文件都以 HTTP 方式加载。 我在 HTTPS 中需要的文件是:login.php,该文件夹称为“forum”。 另外,如果有帮助的话:文件夹中的所有文件都是 *.php。
我正在尝试以下内容:
#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]
当谈到 mod_rewrite 时,我有点业余,所以如果上面的内容完全关闭,请原谅我。 另外,如果您发布一个解决方案,如果您发布它并附上解释,我将不胜感激,这样我就可以真正了解它是如何工作的。
提前致谢! 大卫
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.
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.
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.
Thanks in advance!
David
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
尝试一下:
Give this a try:
尝试这些规则:
Try these rules: