2014-10-01 35 views
-1

我正在使用此htaccess代碼。我希望任何電話都可以撥打https://www.mysite.com/theme/topic。我真的看了很多鏈接&幫助 - 結果是唯一和永遠對於任何請求,從http重寫爲https結果index.php

https://www.example.com/index.php

所以/主題/題目是不是在輸出的URL,僅在index.php

什麼這裏錯了嗎?感謝您的幫助

<IfModule mod_rewrite.c> 
    RewriteEngine On 
    RewriteBase/

    ### If file exists, use it. 
    RewriteCond %{REQUEST_FILENAME} !-f 
    RewriteCond %{REQUEST_FILENAME} !-d 
    RewriteCond %{REQUEST_FILENAME} !-l 

    RewriteRule ^(.*)$ index.php [L] 

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

    RewriteCond %{HTTPS} off 
    RewriteRule ^(.*)$ https://www.example.com/$1 [L,QSA,R=301] 
</IfModule> 
+2

可能重複[HTTP到HTTPS槽htaccess的(http://stackoverflow.com/questions/10489895/http-to-https-through-htaccess) – Azrael 2014-10-01 14:24:21

+0

我我試過這個解決方案(RewriteRule ^。* $ https://%{SERVER_NAME}%{REQUEST_URI} [R,L]),謝謝你的提示。結果是一樣的:只有index.php頁面 – 2014-10-01 15:08:40

回答

0

你就自己說:

所以/主題/題目是不是在輸出的URL,僅在index.php

試圖改變線

RewriteRule ^(.*)$ index.php [L] 

RewriteRule ^(.*)$ /theme/topic/$1 [L] 

還是有一個特定的原因爲什麼不把它放在那裏?

[編輯後澄清]

所以,你有2個動態參數,並要重寫yourdomain.com/parameter1/parameter2yourdomain.com/index.php?p1=parameter1&p2=parameter2?然後,請嘗試以下操作:

RewriteRule ^([^/\.]+)/([^/\.]+)/?$ index.php?p1=$1&p2=$2 [L] 

哦[更多澄清後重新編輯],所以它只是從HTTP重定向到HTTPS,重定向到www?然後,你可以做到以下幾點:的

<IfModule mod_rewrite.c> 
RewriteEngine On 
RewriteBase/

RewriteCond %{HTTP_HOST} !^www\. [NC, OR] 
RewriteCond %{HTTPS} !on 
RewriteRule ^.*$ https://www.mysite.com/%{REQUEST_URI} [R=301,L] 
</IfModule> 
+0

yes:無論主題或主題是什麼,(它們都是動態的) - 重定向應該是從http - >無論哪個uri到https - >任何uri – 2014-10-01 15:12:28

+0

我的編輯解決了你的問題嗎?如果是這樣,請標記爲已解決。 – DaveG 2014-10-03 06:08:09

+0

對於遲到的回覆@DaveG感到抱歉。 我想重寫 'http://example.com/parameter1/parameter2/ ...' 到: 'https://www.example.com/parameter1/parameter2/ ...' 我得到的是: 'https:// www.example.com/index.php' – 2014-10-06 19:32:24