php - 重定向太多 .htaccess
问题描述
我有网站。在以前的主机上,我的文件没有任何问题.htaccess
。现在我有一些问题TOO_MANY_REDIRECTS
。我需要将所有请求从yzerkalo.ru
或重定向www.yzerkalo.ru
到https://**
我有这个.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>
解决方案
尝试这个。
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>
推荐阅读
- javascript - 是否可以部分定义对象类型?
- android - AppWidget中的GridView视图回收
- java - 为电子邮件发送问题 sendgrid
- r - 回归循环
- python-3.x - 如何在python中并行处理多列数据?
- android - 连接mongodb时如何解决android studio中的NoClassDefFound错误?
- python - 在 Ubuntu 上使用 Connexion/Flask 和公共 IP 地址创建 Apache Web 服务器
- angularjs - 使用浏览器的后退按钮后如何重新加载路线?
- vb.net - Visual basic编写最小数程序
- powershell - Powershell.exe 和 Powershell ISE 之间的代码工作方式略有不同 - 对象排序行为