2017-05-28 48 views
1

我有我的託管1and1,我剛拿到一個SSL證書。我現在已經改變了的.htaccess加載.php文件而不是HTML文件,與此代碼工作正常:設置.htaccess去https和php而不是html

RewriteEngine on 

#remove the need for .php extention 
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteCond %{REQUEST_FILENAME}\.php -f 
RewriteRule ^(.*)$ $1.php 

現在我希望自己的網站以https加載,無論是否進入像http://wwwhttp://等等。如果我沒有指定http://http://www,我會從各個地方獲得如此多種不同的方式來完成此操作。所以我想我會一次解決2個問題。該代碼的1and1供應:

RewriteEngine On 
RewriteCond %{HTTP_HOST} !^www\.sitename\.co.uk$ [NC] 
RewriteRule ^(.*)$ https://www.sitename.co.uk/$1 [R=301,L] 

但是,這似乎並沒有做太多的自己的?我可以將2合併爲簡單加載https://www.site的所有內容,並將所有鏈接更改爲加載.php。

回答

0

此作品完美

RewriteEngine On 
RewriteCond %{HTTPS} off 
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} 


RewriteEngine on 
#remove the need for .php extention 
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteCond %{REQUEST_FILENAME}\.php -f 
RewriteRule ^(.*)$ $1.php 
相關問題