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_flag in .htaccess〉

Apache 檔案上傳限制設定

通常上傳檔案會出問題, 都是去修改 php.ini 中的 memory_limit, max_execution_time, post_max_size, upload_max_filesize. 這些參數.

今天才發現到原來 Apache 也會去設定上傳檔案大小(應該是 Redhat 預設 Apache 有做修改).

只要在 httpd.conf 中加入如下.

		<Files *.php>
	SetOutputFilter PHP
	SetInputFilter PHP
	LimitRequestBody 524288
	</Files>
	

將 LimitRequestBody 設為 2000000(2M), 就可以解決掉上傳只能上傳 500kb 的問題.