apache - 我的转发似乎在 .htaccess 中不起作用
问题描述
我在 laravel 网站上遇到 apache .htaccess 重定向问题我的转发似乎在这里不起作用是我想要的:将 www 转发到非 www www.ReplaceMe.com 到 ReplaceMe.com 将 HTTP 转发到 https http:// ReplaceMe.com 到 https://ReplaceMe.com转发 非尾随 / 添加尾随 / https://ReplaceMe.com 到 https://ReplaceMe.com/
所以结果会是。 https://www.ReplaceMe.com/about-us 至 https://ReplaceMe.com/about-us/
但它似乎不起作用。
下面我正在使用的代码:
<IfModule mod_rewrite.c>
<IfModule mod_negotiation.c>
Options -MultiViews -Indexes
</IfModule>
RewriteEngine On
# 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]
# Send Requests To Front Controller...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
# www to non-www
RewriteCond %{HTTP_HOST} ^www.ReplaceMe\.com$ [NC]
RewriteRule ^(.*)$ https://ReplaceMe.com/$1 [R=301,L]
# http to https
RewriteCond %{HTTPS} !=on
RewriteRule ^/?(.*) https://%{SERVER_NAME}/$1 [R=301,L]
</IfModule>
据我所知,这应该有效。谁能发现我的问题?
解决方案
推荐阅读
- node.js - 类似于 Coursera、Udacity 等的视频和电子学习产品究竟如何跟踪用户的查看进度?
- javascript - 使用 JavaScript 混合数组
- android - 使用 nodejs 将套接字浏览器连接到 android 套接字(使用 nodejs javascript 的浏览器)
- django - 在 Django 多对多模型中创建或更新字段
- c++ - 如何使用自定义流操纵器将数据保存在类实例中?
- dotnetnuke - 使用 2sxc 模块将 DNN 新闻导出到其他系统
- c# - 从一个文本框中的数据表值进行操作
- sql - 如何通过外部表解析 id
- json - 使用 System.Text.Json.JsonSerializer 反序列化到 ProblemDetails 时出错。.Net Core 3.0
- android - Unity GoogleMobileAdsMediationTestSuite 抛出异常 setAdListener 必须在主 UI 线程上调用