2016-12-21 44 views
1

我無法使其工作。

之前,我有HTTPS,我有:

RewriteRule ^(.*)$ /$1.php

簡單。請給/page/成爲/page.php

我添加HTTPS:

RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI}

工程。但我不能讓/page//page.php行爲與任何規則了工作,我嘗試創建:

RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI}.php

RewriteRule (.*) https://%{HTTP_HOST}/$1.php

RewriteRule (.*) https://%{HTTP_HOST}$1.php

RewriteRule (.*) https://%{SERVER_NAME}/$1.php

RewriteRule (.*) https://%{SERVER_NAME}/%$1.php

我不知道該怎麼做才能讓HTTP重寫到HTTPS ......工作

編輯: .htaccess

DirectoryIndex index.php <IfModule mod_rewrite.c> RewriteEngine On RewriteCond %{HTTPS} !on RewriteRule (.*) https://%{HTTP_HOST}$1.php </IfModule>

謝謝你的任何援助!

+0

你能告訴您的完整的.htaccess也澄清你的意思是用'工程。但我無法得到.php文件加載anymmore'? – anubhava

+0

添加到帖子,謝謝。 「但是我無法獲得/ page/to /page.php行爲與我嘗試創建的任何規則一起工作:」 – KrNel

+0

這是一個WordPress網站嗎? – chop62

回答

1

您應該使用2個不同的規則:

DirectoryIndex index.php 
RewriteEngine On 

# redirect http to https 
RewriteCond %{HTTPS} off 
RewriteRule^https://%{HTTP_HOST}%{REQUEST_URI} [L,NE,R=301] 

# add .php internally 
RewriteCond %{REQUEST_FILENAME}.php -f 
RewriteRule ^(.+?)/?$ $1.php [L] 
+1

謝謝,把它分開了。 – KrNel

相關問題