[英]redirect http to https for some page in site in APACHE
I want to one of my site's page will use only HTTPS. 我希望我网站的其中一个页面只使用HTTPS。
I have given manually link to all sites to https
. 我手动链接到所有站点到
https
。
But I want that if user manually types that page URL with http
then it should be redirected to https
page. 但我希望如果用户用
http
手动键入该页面URL,则应将其重定向到https
页面。
So if user types: 所以如果用户输入:
http://example.com/application.php
then it should be redirected to 然后它应该被重定向到
https://example.com/application.php
Thanks 谢谢
Avinash 阿维纳什
Here's a couple of lines I used in an .htaccess
file for my blog, some time ago : 不久之前,我在博客的
.htaccess
文件中使用了几行:
RewriteCond %{HTTP_HOST} =www.example.com
RewriteCond %{REQUEST_URI} ^/admin*
RewriteCond %{HTTPS} !=on
RewriteRule ^admin/(.*)$ https://www.example.com/admin/$1 [QSA,R=301,L]
Basically, the idea here is to : 基本上,这里的想法是:
And, if so, redirect to the requested page, using https instead of http. 如果是这样,请使用https而不是http重定向到请求的页面。
I suppose you could use this as a starting point, for your specific case :-) 我想你可以用它作为起点,针对你的具体情况:-)
You'll probably just have to : 你可能只需要:
Edit after the comment : well, what about something like this : 评论后编辑:好吧,这样的事情:
RewriteCond %{HTTP_HOST} =mydomain.com
RewriteCond %{HTTPS} !=on
RewriteRule ^(.*)$ https://mydomain.com/$1 [QSA,R=301,L]
Basically : 基本上:
admin
admin
的部分 Try this rule: 试试这条规则:
RewriteEngine on
RewriteCond %{HTTPS} !=on
RewriteRule ^application\.php$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
This rule is intended to be used in the .htaccess file in the document root of your server. 此规则旨在用于服务器的文档根目录中的.htaccess文件中。 If you want to use it in the server configuration file, add a leading slash to the pattern of
RewriteRule
. 如果要在服务器配置文件中使用它,请在
RewriteRule
模式中添加前导斜杠。
use this: 用这个:
RewriteEngine On
# Turn SSL on for /user/login
RewriteCond %{HTTPS} off
RewriteCond %{REQUEST_URI} ^/user/login
RewriteRule ^(.*)$ https://%{HTTP_HOST}$1 [R=301,L]
# Turn SSL off everything but /user/login
RewriteBase /
RewriteCond %{HTTPS} on
RewriteCond %{REQUEST_URI} !^/user/login
RewriteRule ^(.*)$ http://%{HTTP_HOST}$1 [R=301,L]
open httpd.conf or .htaccess file (mod_rewrite not required): 打开httpd.conf或.htaccess文件(不需要mod_rewrite):
# vim httpd.conf
Append following line : 附加以下行:
Redirect permanent / https://example.com/
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.