You are here: 首頁

飛朵啦學習手札

本網站建議使用Firefox2.0以上,或是使用Goole瀏覽器來瀏覽,並使用1024x768解析度來觀看.

JA slide show

新聞公告

歡迎來到飛朵啦學習手札

16

CI .htaccess for HiHosting主機

E-mail 列印 PDF

本文轉自http://codeigniter.org.tw/forum/viewtopic.php?f=7&t=3900

 


近期把專案程式 (PHP+CI) 交付到客戶承租的 中華電信HiHosting 主機時,

發現 .htaccess 檔案的關係,導致網頁一直未能正常顯示出來 ( 403 Forbidden Error ),

拜求咕狗大神之後,只要在我們原有的.htaccess 檔多加入 Options +FollowSymLinks 就可以了 ;

後來不經意又看到 SymLinksIfOwnerMatchFollowSymLinks 更安全,但效能也許差一些些,

所以再將之修正為 Options -FollowSymLinks +SymLinksIfOwnerMatch

修正過後的 .htaccess 檔如底下所示:

 

代碼:
# -CodeIgniter- TO REMOVE index.php FROM URL
Options -FollowSymLinks +SymLinksIfOwnerMatch
RewriteEngine on
RewriteCond $1 !^(index\.php|images|css|js|robots\.txt|favicon\.ico)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ ./index.php/$1 [L,QSA]   


總言之,對我手上兩個專案客戶都採用HiNet HiHosting 主機時,須使用上方的 .htaccess 網站才能正常運作;

以上,野人獻曝,若有誤導或者更優的 solution 也請板上前輩們不吝指教,謝謝。


## 參考資料如下 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

◎ 底下摘錄自 Apache ( http://jendo.org/files/doc/apache.html )

代碼:
二、路徑的 Options

Options 的參數,可在參數前加上「+」或「-」。Options屬性如果沒有用「+」或者「-」來增加或者減少一個功能的時候,每個之前定義的Options的所有功能都會被取消,直到你又為它指定一些功能。
且options屬性在整體設定和虛擬主機設定上並不相關,互相不起作用,因為他們在各自的範圍內被重載了。
所以如果要在虛擬主機裡面使用在整體設定中的Options功能,那麼就不要在虛擬主機設定中指定Options功能;而是用「+」或者「-」符號來增加或者減少功能。

Options的諸參數如下:
All: 以下諸功能皆有。
None: 以下諸功能皆無。
Indexes: 自動產生目錄的索引,將Indexes拿掉,點選連結目錄就不會秀出目錄來,會改成403 forbidden的訊息頁面。
Includes: 提供 SSI (Server-Side Inclues) 功能,即使用Apache的指令在html檔中寫程式。須先載入 includes_module 。詳見 http://home.educities.edu.tw/shirock/comp/Apache_SSI.htm 。
FollowSymLinks: 遵循符號鏈接,即能夠連到其它的目錄去執行。會壓過SymLinksIfOwnerMatch。
SymLinksIfOwnerMatch: 對符號鏈接及其每一層父資料夾,都進行權限檢查,當連結檔本身的owner跟連結目的地的owner不同時拒絕存取。
ExecCGI:可以執行CGI程式。
MultiViews: 送出多國語言支援的頁面。此功能必須被明確指定,Options All並不會提供這個功能。




◎ 底下摘錄自 Apache Performance Tuning ( http://httpd.apache.org/docs/2.2/misc/perf-tuning.html )

代碼:
FollowSymLinks and SymLinksIfOwnerMatch
Wherever in your URL-space you do not have an Options FollowSymLinks, or you do have an Options SymLinksIfOwnerMatch
Apache will have to issue extra system calls to check up on symlinks. One extra call per filename component. For example,
if you had:

DocumentRoot /www/htdocs
<Directory />
Options SymLinksIfOwnerMatch
</Directory>

and a request is made for the URI /index.html. Then Apache will perform lstat(2) on /www, /www/htdocs, and /www/htdocs/index.html.
The results of these lstats are never cached, so they will occur on every single request.
If you really desire the symlinks security checking you can do something like this:

DocumentRoot /www/htdocs
<Directory />
Options FollowSymLinks
</Directory>

<Directory /www/htdocs>
Options -FollowSymLinks +SymLinksIfOwnerMatch
</Directory>

This at least avoids the extra checks for the DocumentRoot path. Note that you'll need to add similar sections if you have any Alias
or RewriteRule paths outside of your document root. For highest performance, and no symlink protection,
set FollowSymLinks everywhere, and never set SymLinksIfOwnerMatch.
 
 
13

PHP OWASP 漏洞補救

E-mail 列印 PDF

1. Cookie set without HttpOnly flag

原因:意思是:httponly設置為true則只能通過http操縱cookie,這樣防止了javascript等腳本語言對cookie做修改,幫助我們有效的防止XSS攻擊.

解決方法:

PHP中的設置

PHP5.2以上版本已支持HttpOnly參數的設置,同樣也支持全局的HttpOnly的設置,在php.ini中

-------------------------------------------------- ---

session.cookie_httponly =

-------------------------------------------------- ---

設置其值為1或者TRUE,來開啟全局的Cookie的HttpOnly屬性,當然也支持在代碼中來開啟:

-------------------------------------------------- ---

<?php ini_set("session.cookie_httponly", 1);

// or session_set_cookie_params(0, NULL, NULL, NULL, TRUE);

?>

最近更新 ( 週一, 13 十月 2014 15:28 )
 
 
07

有關於PHP 取得IP所產生的SQL injection

E-mail 列印 PDF

轉自:http://devco.re/blog/2014/06/19/client-ip-detection/

 

很多網站都會有偵測使用者 IP 的功能,不管是判斷使用者來自哪邊,或者是記錄使用者的位置。但是你知道嗎?網路上大多數的教學全部都是「錯誤」的。正確的程式寫法可以確保知道訪客的 IP,但是錯誤的寫法卻可能讓網站管理者永遠不知道犯罪者的來源。

這次我們單就偵測 IP 的議題來探討各種錯誤的寫法。

你知道網路上的教學是不安全的嗎?

 
更多文章...
第 9 頁, 共 50 頁