2017-08-16 103 views
0

至於建議here,我使用下面的代碼Apache的配置文件(在這種情況下,默認的ssl.conf)HTTP重定向不重定向

<VirtualHost *:80> 
    ServerName name.domain.com 
    Redirect/https://name.domain.com/ 
</VirtualHost> 

我已經重新啓動Apache和什麼都沒有。沒有錯誤,沒有重定向。 Http用作http,https用作https。我做錯了什麼?我的域名不是以「www」開頭的,但我無法想象這會有所作爲。

回答

0

不知道這是否有幫助,也有一段時間的瀏覽器劑量DNS緩存嘗試清除它,在Chrome中,你可以轉到Chrome:// net-internals /#dns並清除它,或使用其他瀏覽器進行測試。

<VirtualHost *:80> 
    DocumentRoot /home/webroot/example.com/htdocs 

    ServerName example.com 
    ServerAlias www.example.com 

    <Directory /home/webroot/example.com/htdocs> 
    FileETag MTime Size 
    DirectoryIndex index.php index.html index.htm 
    AllowOverride All 
    Order allow,deny 
    Allow from all 
    </Directory> 

    RewriteEngine on 
    Redirect permanent/http://www.example.com/ 
    RewriteRule^https://%{SERVER_NAME}%{REQUEST_URI} [END,QSA,R=permanent] 

    ErrorLog /home/webroot/example.com/logs/error_log 
    CustomLog /home/webroot/example.com/logs/access_log combined 
</VirtualHost> 

<VirtualHost *:80> 
    DocumentRoot /home/webroot/example.com/htdocs 

    ServerName www.example.com 

    RewriteEngine on 
    Redirect permanent/http://www.example.com/ 
    RewriteRule^https://%{SERVER_NAME}%{REQUEST_URI} [END,QSA,R=permanent] 

    ErrorLog /home/webroot/example.com/logs/error_log 
    CustomLog /home/webroot/example.com/logs/access_log combined 
    RewriteRule^https://%{SERVER_NAME}%{REQUEST_URI} [END,NE,R=permanent] 
</VirtualHost> 
+0

這也沒有效果(正面或負面)。絕對不是DNS緩存問題。似乎之間的所有內容都被忽略了...... – Stumbler

+0

我編輯了我的答案看看是否有幫助,也不要忘記重新啓動httpd –

+0

感謝您的幫助。我意識到問題所在。 default-ssl.conf僅用於使用ssl進行配置,並且在該階段告訴它有關http的任何信息已爲時太晚。你描述的代碼,如果放在000-default.conf(ubuntu服務器14.4)中,可以。 – Stumbler