php_flag in .htaccess

看了 php_flag in .htaccess 這篇文章, 相當的實用.

htaccess 還有很多的功能, 簡單的來列一些.

ex:

DirectoryIndex index.html index.htm index.php
AddType application/x-httpd-php .html .htm
php_value auto_prepend_file /.../refer.php
php_value default_charset utf-8

上面四行意思為.

  1. 此頁面預設的頁面要抓哪個. 依序排列.
  2. 將 .html, .htm 也當 .php 一樣, 輸出前要經過處理.
  3. 在每個檔案前面都加上 refer.php
  4. 設定預設語系為 UTF-8

可能蠻多人都有碰過, 比如說租了主機放php的網頁, 但剛好需要設定一些php.ini的參數, 可是別人的主機應該不能讓你改php.ini, 例如想設定register_globals=off, 那只好透過.htaccess, 在.htaccess中設定

php_flag register_globals off

就會有相同的效果

如果要讓"許"這些字不會變成"許", 除了用stripslashes也可以加入magic_quotes_gpc=off

php_flag magic_quotes_gpc off



更多推薦文章

This work, unless otherwise expressly stated, is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License.

About Tsung

對新奇的事物都很有興趣, 喜歡簡單的東西, 過簡單的生活.
This entry was posted in 未分類. Bookmark the permalink.

2 Responses to php_flag in .htaccess

  1. 华晨 says:

    最后一个示例最有用,但是有的虚拟主机上好像 .htaccess 不支持 php_flag

  2. Tsung says:

    嗯, 看虛擬主機商囉~ 有些是有開放的~ :)

發表迴響

您的電子郵件位址並不會被公開。 必要欄位標記為 *

*

您可以使用這些 HTML 標籤與屬性: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>