首页 > 解决方案 > 重定向太多 .htaccess

问题描述

我有网站。在以前的主机上,我的文件没有任何问题.htaccess。现在我有一些问题TOO_MANY_REDIRECTS。我需要将所有请求从yzerkalo.ru或重定向www.yzerkalo.ruhttps://** 我有这个.htaccess文件:

RewriteEngine On
RewriteBase /
php_flag display_errors Off

RewriteCond %{HTTPS} !=on
RewriteRule ^.*$ https://%{SERVER_NAME}%{REQUEST_URI} [R,L]
RewriteCond %{HTTP_HOST} ^www.yzerkalo\.ru$ [NC]
RewriteRule ^(.*)$ https://yzerkalo.ru/$1 [R=301,L]

RewriteRule ^sitemap\.xml$ sitemap.xml [L]


RewriteCond %{REQUEST_FILENAME} -s [OR]
RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^.*$ - [L]
RewriteRule ^.*$ index.php [L]

# One month for most static assets
<filesMatch ".(css|jpg|jpeg|png|gif|js|ico)$">
Header set Cache-Control "max-age=2628000, public"
</filesMatch>

我做错了什么?这就是我在谷歌浏览器中看到的在此处输入图像描述

标签: php.htaccessvds

解决方案


尝试这个。

RewriteEngine On
RewriteBase /
php_flag display_errors Off

RewriteCond %{HTTP_HOST} ^yzerkalo\.ru [NC]
RewriteCond %{SERVER_PORT} 80
RewriteRule ^(.*)$ https://www.yzerkalo.ru/$1 [R=301,L]

RewriteRule ^sitemap\.xml$ sitemap.xml [L]


RewriteCond %{REQUEST_FILENAME} -s [OR]
RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^.*$ - [L]
RewriteRule ^.*$ index.php [L]

# One month for most static assets
<filesMatch ".(css|jpg|jpeg|png|gif|js|ico)$">
Header set Cache-Control "max-age=2628000, public"
</filesMatch>

推荐阅读