apache的斜杠问题
APACHE默認(rèn)情況下,網(wǎng)頁目錄的最后必須加入斜杠“/",比如
可以瀏覽http://www.example.com/abc/,但是不能瀏覽http://www.example.com/abc,就是說瀏覽目錄時(shí)最后必須加/ 改一下設(shè)置文件,在httpd.conf里,找到
UseCanonicalName On
把On修改為Off就可:
UseCanonicalName Off
就可以了
當(dāng)然也可用mod_rewrite來解決,首先要確認(rèn)你的apache里已經(jīng)安裝了這module,且你的httpd.conf里起用了rewrite,才可以調(diào)用.htaccess
# This controls which options the .htaccess files in directories can
# override. Can also be "All", or any combination of "Options", "FileInfo",
# "AuthConfig", and "Limit"
#
??? AllowOverride all
當(dāng)向服務(wù)器請求的是
http://www.example.com/faq而不是http://www.example.com/faq/時(shí)
,服務(wù)器就會去查找一個(gè)叫faq的文件,而實(shí)際上faq是目錄,所以就會報(bào)錯(cuò),無法自動跳轉(zhuǎn)。
解決方法:
編輯用戶網(wǎng)站主目錄下的.htaccess文件:
在DocumentRoot下,建立.htaccess文件,寫進(jìn)如下內(nèi)容:
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^(.+[^/])$ http://www.example.com/$1/ [R=301]
這樣,服務(wù)器就會自動添加后綴斜杠,實(shí)現(xiàn)自動跳轉(zhuǎn)。
Apache中ErrorDocument文件的設(shè)置問題
在httpd.conf中設(shè)置 ErrorDocument 404 /missing.html
但其中的內(nèi)容死活不能用,原來是IE的一個(gè)BUG,錯(cuò)誤文件需要大于512字節(jié)才能正常被顯示。
教訓(xùn):
1.手冊是好東西,一定要細(xì)心去看。
2.很多情況下應(yīng)該換個(gè)角度去思考問題。在本例中,把IE中的 "Show Friendly HTTP Error Messages"(ie里設(shè)置“顯示友好的http錯(cuò)誤信息)打開后,就一切迎刃而解了。
使訪問http的轉(zhuǎn)向到https
RewriteEngine On
# For webmail
RewriteCond %{HTTP_HOST} ^webmail\.lwkp\.com\.cn
RewriteCond %{HTTP_HOST} !^$
RewriteCond %{SERVER_PORT} ^80$
RewriteRule (.*) https://www.xxx.com[L,R]
# For IP
RewriteCond %{SERVER_PORT} ^80$
RewriteCond %{HTTP_HOST} ^xx\.xx\.xxx9\.[1-9]*$
RewriteRule (.*) https://%{HTTP_HOST}/
轉(zhuǎn)載于:https://www.cnblogs.com/baogg/articles/2090805.html
總結(jié)
以上是生活随笔為你收集整理的apache的斜杠问题的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: JS通用窗口拖动函数
- 下一篇: 关于selecteditem.value