[请益] 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