php - Htaccess 代码正在创建永无止境的重定向
问题描述
我的 htaccess 文件中有以下内容,并且我的网站使用 SSL。如果我只保留第 1 部分,则该网站可以正常工作。否则,如果我也添加第 2 部分,该站点将无法打开;发生连续重定向。我想知道我做错了什么。这将帮助我解决问题。mydomainname.com 是例如我的网站域名。请指教。
# Part 1
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{SERVER_PORT} 80
RewriteRule ^(.*)$ https://www.mydomainname.com/$1 [R,L]
#</IfModule>
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress
# Part 2
# Begin Disable hotlinking and leeching
RewriteEngine on
RewriteCond %{HTTP_REFERER} !^$
RewriteCond %{HTTP_REFERER} !^http(s)?://(www\.)?mydomainname.com [NC]
RewriteCond %{HTTP_REFERER} !^http(s)?://(www\.)?google.com [NC]
RewriteCond %{HTTP_REFERER} !^http(s)?://(www\.)?feeds2.feedburner.com/mydomainname [NC]
RewriteRule \.(jpg|jpeg|png|gif)$ – [NC,F,L]
# End Disable hotlinking and leeching
<filesMatch ".(ico|pdf|flv|jpg|jpeg|png|gif|js|css|swf)$">
Header set Cache-Control "max-age=84600, public"
</filesMatch>
## EXPIRES HEADER CACHING ##
<IfModule mod_expires.c>
ExpiresActive On
ExpiresByType image/jpg "access 1 year"
ExpiresByType image/jpeg "access 1 year"
ExpiresByType image/gif "access 1 year"
ExpiresByType image/png "access 1 year"
ExpiresByType text/css "access 1 month"
ExpiresByType application/pdf "access 1 month"
ExpiresByType application/javascript "access 1 month"
ExpiresByType application/x-javascript "access 1 month"
ExpiresByType application/x-shockwave-flash "access 1 month"
ExpiresByType image/x-icon "access 1 year"
ExpiresDefault "access 2 days"
</IfModule>
## EXPIRES HEADER CACHING ##
Redirect 301 /programs/ /programs/
Redirect 301 /webinar/ /media/
# BEGIN EWWWIO
# END EWWWIO
解决方案
推荐阅读
- ios - 在 ios 14 中设置新权限“限制”时获取列表照片
- python - 如何在暗网中使用预训练的 yolov4 模型训练新课程
- django - 你能阻止 Django 自动恢复手动迁移吗?
- python - mitmmproxy 捕获到 python 的数据
- clickhouse - 在 Clickhouse 中创建物化视图超时
- javascript - 如何使用 JSOM 更改 SharePoint 在线列表的列类型?
- arrays - vba 数组 - 处理数组保留维度之外的条件
- linux - 当没有 Internet 连接时,如何将扩展安装到作为 Remote-SSH 远程端的 VS Code Server 中?
- c# - 将日期时间转换为字符串格式并将其传递给查询
- file - Google Cloud Storage 上文件列表的一致性