[請益] apache隱藏副檔名及http轉https
各位前輩好,
最近在測試用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
先謝謝各位了 ><
--
※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 114.136.191.11
※ 文章網址: https://www.ptt.cc/bbs/PHP/M.1459439192.A.BBB.html
→
04/01 00:08, , 1F
04/01 00:08, 1F
→
04/01 00:08, , 2F
04/01 00:08, 2F
討論串 (同標題文章)
以下文章回應了本文:
完整討論串 (本文為第 1 之 2 篇):
PHP 近期熱門文章
PTT數位生活區 即時熱門文章