简体   繁体   English

重定向一个 url 到 https - .htaccess

[英]Redirect one url to https - .htaccess

I have been browsing around trying to find a simple way to redirect 1 url to https://我一直在浏览,试图找到一种简单的方法将 1 url 重定向到 https://

To be more clear, I am trying to do:为了更清楚,我正在尝试做:

http://www.google.com/page-name/ to go to https://www.google.com/page-name http://www.google.com/page-name/到 go 到https://www.google.com/page-name

I found many solutions out there but were all customized to the sites spec.我在那里找到了许多解决方案,但都是根据网站规范定制的。 Would it be a simple会不会很简单

redirect XX XX重定向 XX XX

If you are trying to force every page to https then following code will work for you in your .htaccess file:如果您试图将每个页面强制为 https 那么以下代码将在您的 .htaccess 文件中为您工作:

Options +FollowSymlinks -MultiViews
RewriteEngine on

RewriteCond %{SERVER_PORT} =80
RewriteRule . https://%{HTTP_HOST}%{REQUEST_URI} [R=301,NE,L]

EDIT or to force https on just a specific page securedpage.html use this code:编辑或仅在特定页面上securedpage.html使用此代码:

RewriteCond %{SERVER_PORT} =80
RewriteRule ^securedpage\.html$ https://%{HTTP_HOST}%{REQUEST_URI} [R=301,NE,L]

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

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