2016-10-25 60 views

回答

0

一種方法是詢問您的DNS提供商重定向。

另一種方式獲取此其他計算器問題解釋說:.htaccess - how to force "www." in a generic way? 基本上下面應該工作:

RewriteCond %{HTTP_HOST} !^www\.example\.com$ [NC] RewriteRule ^(.*)$ http://www.example.com/$1 [R=301,L]

+0

我們使用route53。我們無法在DNS級別執行更多的操作,而我的網站在AWS負載平衡器上運行的更多.. – Raj

+0

我們嘗試過但其不工作 – Raj

+0

我的例子已經用於'http'地址。嘗試將其更改爲「https」。 – spitterfly

0

從HTTP非www重定向您的網站https://www您可以使用以下規則:

RewriteEngine on 

RewriteCond %{HTTP_HOST} !^www\. 
RewriteCond %{HTTPS} off 
RewriteRule^https://www.example.com%{REQUEST_URI} [NE,L,R] 
+0

我需要將https://example.com重定向到https://www.example.com。 – Raj

+0

其不工作 – Raj

+0

其不工作:( – Raj

0

如果你使用Apache作爲你的網站,你可以使用別名

<VirtualHost *:443> 
    ServerName www.example.com 
    ServerAlias example.com 

    ServerAdmin [email protected] 
    DocumentRoot /var/www/devops_blog 
    <Directory /var/www/devops_blog> 
     Options All 
     AllowOverride All 
     Require all granted 
    </Directory> 
0

試試這個

RewriteEngine on 
RewriteCond %{HTTPS_HOST} ^example\.com$ [NC] 
RewriteRule ^(.*)$ https://www.example.com/$1 [R=301,L]