簡體   English   中英

wordpress htaccess http www重定向到https non-www

[英]wordpress htaccess http www redirect to https non-www

我已經閱讀了很多這樣的帖子,我的頭上絕對是游泳,而且我嘗試的任何方法似乎都無法正常工作。 我的網站是http:// www,我已在wordpress設置中將其更改為https://(非www)(我安裝了ssl證書)

我有一個現有的.htaccess文件。
我無法弄清楚如何調整現有的.htaccess以便將所有請求重定向到https://(非www)。有人可以給我完整的代碼,簡單說明我的htaccess應該是什么嗎?

這是我現有的htaccess文件:

# BEGIN WordPress
<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
# php -- BEGIN cPanel-generated handler, do not edit
# Set the “ea-php70” package as the default “PHP” programming language.
<IfModule mime_module>
  AddType application/x-httpd-ea-php70 .php .php7 .phtml
</IfModule>
# php -- END cPanel-generated handler, do not edit

<Files 403.shtml>
order allow,deny
allow from all
</Files>

根據這篇文章,您可以更改.httaccess文件以重定向:

http://example.com
http://www.example.com
https://example.com


https://example.com

使用

RewriteEngine On
RewriteCond %{HTTPS} off [OR]
RewriteCond %{HTTP_HOST} ^www\. [NC]
RewriteCond %{HTTP_HOST} ^(?:www\.)?(.+)$ [NC]
RewriteRule ^ https://%1%{REQUEST_URI} [L,NE,R=301]

只需在.htaccess文件中的#end wordpress之后添加此代碼。
保存.htaccess文件后,請記住將您的永久鏈接結構保存在settings->permalink

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM