[請益] apache隱藏副檔名及http轉https

作者: Moon008 (008)   2016-03-31 23:46:26
各位前輩好,
最近在測試用Apache架站,希望可以將網頁的副檔名隱藏起來,並且強制使用https連線
假設目前網頁有:
index.php
about.html
contact.php
我希望呈現的是:
https://domain.com/ (index.php)
https://domain.com/about (about.html)
https://domain.com/contact (contact.php)
在使用https之前,我是使用.htacess的方式,放在根目錄下,設定為:
RewriteEngine on
RewriteBase /
RewriteRule ^([A-Za-z0-9_-]+)$ $1.html
可是這樣子沒辦法辨識該網頁應該是.php還是.html
不知道有沒有辦法同時適用?
另外就是因為目前希望全站都透過https連線,
可是我將上方的規則修改如下之後:
RewriteEngine on
RewriteBase /
RewriteCond %{SERVER_PORT} !443
RewriteRule ^([A-Za-z0-9_-]+)$ https://%{SERVER_NAME}/$1.html
一來是我如果直接輸入:domain.com連入,會預設以http連線,
且我再點網頁上的連結到別頁(例如href="about")
卻會把副檔名也加上去(變成https://domain.com/about.html)
不知道我的需求使用Rewrite是否可以完全達到呢?
因為爬文似乎都是分開說明(針對.php或https)
努力結合了幾次仍然失敗..QQ
先謝謝各位了 ><
作者: imhaha (嘿嘿)   2016-04-01 00:08:00
https 你用這個寫法http://izo.tw/cpanel-ssl/

Links booklink

Contact Us: admin [ a t ] ucptt.com