【问题标题】:htaccess redirect 301 to form https://www.domain.plhtaccess 重定向 301 以形成 https://www.domain.pl
【发布时间】:2018-07-15 19:10:40
【问题描述】:

我尝试了许多潜在的 htaccess 解决方案来实现表单https://www

这些解决方案中的大多数仅在四种情况下的三种情况下取​​得了良好的效果:

http://example.com -> https://www.example.com
http://www.example.com -> https://www.example.com
https://www.example.com -> https://www.example.com
https://example.com -> https://example.com - ERROR !

现在我的 .htaccess 如下所示:

选项 -MultiViews -Indexes

RewriteEngine On

RewriteCond %{SERVER_PORT} !=443 [OR]
RewriteCond %{HTTP_HOST} !^www\.
RewriteRule ^(.*)$ https://www.medconnect.pl/$1 [R=301,L]

# Handle Authorization Header
RewriteCond %{HTTP:Authorization} .
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]

# Redirect Trailing Slashes If Not A Folder...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} (.+)/$
RewriteRule ^ %1 [L,R=301]

# Handle Front Controller...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]

我哪里出错了?

【问题讨论】:

    标签: laravel apache .htaccess redirect


    【解决方案1】:

    这在我的网站上得到了解决。你可以检查一下

    RewriteEngine On
    RewriteCond %{HTTPS} !=on
    RewriteRule ^(.*)$ https://www.example.com/$1 [R=301,L]
    

    它会重写所有针对 http(带或不带 www)、https://www.example.com/ 的站点请求

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2014-09-08
      • 1970-01-01
      • 2017-09-21
      • 1970-01-01
      • 2017-05-03
      • 2017-04-23
      • 2011-05-01
      • 2011-01-03
      相关资源
      最近更新 更多