如何更改.htaccess文件重定向到www,而不是http?而不是、重定向、如何更改、文件

2023-09-02 09:55:42 作者:Deprecating(自嘲)

下面是code。在我的.htaccess文件。如何更改它重定向访问者的https:// WWW ,而不是的http://

 选项+了FollowSymLinks
RewriteEngine叙述上

的RewriteCond%{} REQUEST_FILENAME!-f
的RewriteCond%{} REQUEST_FILENAME!-d

重写规则。的index.php [L]
 

解决方案

紧随 RewriteEngine叙述在指令后,将以下内容:

 的RewriteCond%{} HTTPS关闭[OR]
的RewriteCond%{HTTP_HOST}!WWW 。
重写规则* HTTPS://www.example.com% {REQUEST_URI} [R = 301,L]
 

这将同时处理 HTTP HTTPS 非www WWW 重定向。需要注意的是外部重定向通常应该来的在的内部重写(这是您当前拥有)。

laravel修改.htaccess文件重定向public的解决方法 其它代码类资源 CSDN下载

Below is the code in my .htaccess file. How do I change it to redirect visitors to https://www and not http://.

Options +FollowSymLinks
RewriteEngine on

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d

RewriteRule . index.php [L]

解决方案

Immediately after the RewriteEngine On directive, place the following:

RewriteCond %{HTTPS} off [OR]
RewriteCond %{HTTP_HOST} !www.
RewriteRule .* https://www.example.com%{REQUEST_URI} [R=301,L]

This will handle both the http to https and non-www to www redirection. Note that external redirections should generally come before internal rewrites (which is what you currently have).