最後更新: 2017-09-27




Enable .htaccess


用得 .htaccess 的 Folder 要有以下設定

<Directory "">
    AllowOverride All

AllowOverride 說明


某些目錄有 auto indexing


Options +Indexes

P.S. 設定某 Folder 不 show

Options All -Indexes


Files & FilesMatch


設定不同的 Error Page


ErrorDocument 401 /error/401.php
ErrorDocument 403 /error/403.php
ErrorDocument 404 /error/404.php
ErrorDocument 500 /error/500.php


寫 rewrite rule

RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} ^ [NC]
RewriteRule ^(.*)$$1 [L,R=301]





Redirect 301


設定 cache ttl


<FilesMatch ".(flv|gif|jpg|jpeg|png|ico|swf|js|css|pdf)$">
Header set Cache-Control "max-age=2592000"



設定不用的 Default page


DirectoryIndex business.html


Download only Folder


# Turn off all options we don't need.
Options None
Options +FollowSymLinks

# If we know how to do it safely, disable the PHP engine entirely.
<IfModule mod_php5.c>
  php_flag engine off


Private Folder


Deny from all


在某 Sub-Folder 不用 login



# apache 2.2
Satisfy Any

# apache 2.4
Require all granted