首页 > 解决方案 > 我的转发似乎在 .htaccess 中不起作用

问题描述

我在 laravel 网站上遇到 apache .htaccess 重定向问题我的转发似乎在这里不起作用是我想要的:将 www 转发到非 www www.ReplaceMe.com 到 ReplaceMe.com 将 HTTP 转发到 https http:// ReplaceMe.comhttps://ReplaceMe.com转发 非尾随 / 添加尾随 / https://ReplaceMe.comhttps://ReplaceMe.com/

所以结果会是。 https://www.ReplaceMe.com/about-ushttps://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>

据我所知,这应该有效。谁能发现我的问题?

标签: apache.htaccessredirect

解决方案


推荐阅读