繁体   English   中英

htaccess WordPress 301重定向

[英]htaccess wordpress 301 redirect

我最近将SSL添加到了我的wordpress网站,现在如果某些链接转到了我的http网站,我想将它们重定向到我的https网站。 我尝试了以下方法:

# BEGIN WordPress 
<IfModule mod_rewrite.c> 
RewriteEngine On 
RewriteBase / 
RewriteRule ^index\.php$ - [L] 
RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{HTTPS} !=on
RewriteRule ^/?(.*) https://%{SERVER_NAME}/$1 [R,L] 
RewriteRule . /index.php [L] 
</IfModule> 
# END WordPress

但是得到了这个错误

Error 310 (net::ERR_TOO_MANY_REDIRECTS): There were too many redirects.

我究竟做错了什么?

这是用于实施https的代码:

# BEGIN WordPress 
<IfModule mod_rewrite.c> 
RewriteEngine On 
RewriteBase / 

RewriteCond %{HTTPS} !=on
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L] 

RewriteRule ^index\.php$ - [L] 

RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L] 
</IfModule> 
# END WordPress

尝试这个 :

RewriteEngine on

RewriteCond %{SERVER_PORT} 80

RewriteRule ^(.*)$ https://{SERVER_NAME}/$1 [R=301,L]

RewriteCond %{HTTP_HOST} ^www\.(.*)

RewriteRule ^(.*)$ https://{SERVER_NAME}/$1 [R=301,L]

RewriteCond %{HTTP_HOST} ^http://\.(.*)

RewriteRule ^(.*)$ https://{SERVER_NAME}/$1 [R=301,L]

RewriteCond %{REQUEST_FILENAME} -s [OR]

RewriteCond %{REQUEST_FILENAME} -l [OR]

RewriteCond %{REQUEST_FILENAME} -d

RewriteRule ^.*$ - [NC,L]

RewriteRule ^.*$ /index.php [NC,L]

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM