【问题标题】:Redirect one url to https - .htaccess将一个 URL 重定向到 https - .htaccess
【发布时间】:2011-05-23 17:48:10
【问题描述】:

我一直在四处浏览,试图找到一种将 1 url 重定向到 https://

的简单方法

为了更清楚,我正在尝试做:

http://www.google.com/page-name/ 转至https://www.google.com/page-name

我找到了许多解决方案,但都是根据网站规范定制的。会不会很简单

重定向 XX XX

【问题讨论】:

  • 你能澄清你的问题吗?您是指将所有页面重定向到一个页面吗?
  • 更新了我上面的问题。谢谢!

标签: regex .htaccess redirect


【解决方案1】:

如果您试图强制 每个 页面使用 https,那么以下代码将在您的 .htaccess 文件中为您工作:

Options +FollowSymlinks -MultiViews
RewriteEngine on

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

编辑或仅在特定页面上强制 https securedpage.html 使用此代码:

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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2016-02-25
    • 1970-01-01
    • 2013-04-10
    • 1970-01-01
    • 1970-01-01
    • 2014-12-13
    • 2015-02-13
    • 1970-01-01
    相关资源
    最近更新 更多