簡體   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