.htaccess - 将整个域从非 www 重定向到 www 和 HTTP 到 HTTPS
问题描述
我正在尝试将非 www 重定向到 www 和 http 到 https
AddHandler application/x-httpd-ea-php71 .php .php7 .phtml
</IfModule>
# php -- END cPanel-generated handler, do not edit
# BEGIN Spark
Options -Indexes -MultiViews +FollowSymLinks
AddDefaultCharset UTF-8
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)/$ /$1 [L,R=301]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^ index.php [QSA,L]
</IfModule>
# END Spark
RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteRule ^ https://www.%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
RewriteCond %{HTTP:X-Forwarded-Proto} !https
RewriteCond %{HTTPS} off
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
问题帖子链接重定向到 index.php
如何做到这一点 http://domian.com/post-1.html 到 https://www.domian.com/post-1.html
解决方案
作品现在认为@cbroe
# php -- BEGIN cPanel-generated handler, do not edit
# Set the “ea-php71” package as the default “PHP” programming language.
<IfModule mime_module>
AddHandler application/x-httpd-ea-php71 .php .php7 .phtml
</IfModule>
# php -- END cPanel-generated handler, do not edit
# BEGIN Spark
Options -Indexes -MultiViews +FollowSymLinks
AddDefaultCharset UTF-8
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteRule ^ https://www.%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
RewriteCond %{HTTP:X-Forwarded-Proto} !https
RewriteCond %{HTTPS} off
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)/$ /$1 [L,R=301]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^ index.php [QSA,L]
</IfModule>
# END Spark
推荐阅读
- java - 当我尝试从数据库的数据中命名 JLabel 时,我的代码显示 java.lang.NullPointerException。我该如何解决?
- swift - 在加载视频之前显示黑屏
- sas - SAS:根据减少月份获取数字列表
- java - JavaFX - 在 ListView 中创建不可选择的项目
- java - 为什么使用 JUnit 测试 Feign 客户端案例 java.lang.IllegalStateException: Shutdown in progress
- html - div 表不工作
- java - 如何创建自动完成列表
- 父元素
- 元素包含属性 style="display: none;" 通过 Java Selenium
- 父元素
- php - 为 Codeigniter 登录进行过滤
- python - 通过某些(索引)参数将值插入熊猫数据框中的“适当”位置的最佳方法是什么?
- abap - 更改 ALV 网格中附加数据的颜色