首页 > 解决方案 > 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    

标签: phpwordpress.htaccessmod-rewriteurl-rewriting

解决方案


推荐阅读