.htaccess - 将http重定向到https排除特定网址 [英] .htaccess - redirect http to https exclude specific url
本文介绍了.htaccess - 将http重定向到https排除特定网址的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何将http重定向到https排除特定网址?
How to redirect http to https exclude specific url?
http://www.example.com/* => https://www.example.com/*
http://www.example.com/nonssl/* => http://www.example.com/nonssl/*
所以我在此之后制作.htaccess文件:
So I make .htaccess file following this:
RewriteEngine On
RewriteCond %{HTTPS} off
RewriteCond %{REQUEST_URI} !^/nonssl/
RewriteRule .* https://%{HTTP_HOST}%{REQUEST_URI} [R,L]
但是当我去 http://www.example.com/nonssl/testfunc
时,它会转到 https:// www .example.com / index.php / nonssl / testfunc
。
But when I go to http://www.example.com/nonssl/testfunc
, it goes to https://www.example.com/index.php/nonssl/testfunc
.
提前致谢。
推荐答案
对于这个问题,我没有找到正确的方法,只描述要从http重定向到https的所有服务。
For this problem, I didn't find the correct way, just describe all services to redirect from http to https.
RewriteEngine On
RewriteCond %{HTTPS} off
RewriteCond %{REQUEST_URI} ^/$ [OR]
RewriteCond %{REQUEST_URI} ^/test [OR]
RewriteCond %{REQUEST_URI} ^/test1 [OR]
RewriteCond %{REQUEST_URI} ^/test2
RewriteRule ^(.*)$ https://www.example.com/$1 [R,L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond $1 !^(index\.php|images|css|fonts|js|robots\.txt)
RewriteRule ^(.*)$ index.php?/$1 [L]
我知道它不是推荐的方式。如果谁可以解决这个问题,请联系我。
谢谢。
I know it just not recommended way. If who can fix this problem just connect me. Thanks.
这篇关于.htaccess - 将http重定向到https排除特定网址的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文