1. 檢查apache的版本
Apache 1.x 的加載模塊代碼
LoadModule rewrite_module libexec/mod_rewrite.so
AddModule mod_rewrite.c
Apache 2.x 的加載模塊代碼
LoadModule rewrite_module modules/mod_rewrite.so
Apache配置:
------------------------------------------------------------------------------
讓apache服務器支持.htaccess
如何讓自己的本地APACHE服務器支持”.htaccess”呢?其實只要簡單修改一下apache的httpd.conf設置就可以讓APACHE支 持.htaccess了。打開httpd.conf文件用文本編輯器打開後,查找
<Directory />
Options FollowSymLinks
AllowOverride None
</Directory>
改爲
<Directory />
Options FollowSymLinks
AllowOverride All
</Directory>
就可以了。
RewriteEngine On
RewriteBase /
僞靜態
RewriteRule ^(article)-([0-9]+)/.htm$ $1.php/?id=$2
根據IP阻止用戶訪問
order allow,deny
deny from 127.0.0.1
allow from all
Redirects 轉向
Redirect /article.php http://www.baidu.com
防止.htaccess文件被查看
order allow,deny
deny from all
製作錯誤提醒頁面
ErrorDocument 404 http://www.baidu.com
添加 MIME 類型
AddType application/x-shockwave-flash swf
Tips: 設置類型爲 application/octet-stream 將提示下載
改變缺省的首頁文件
DirectoryIndex aa.html index.html index.pl default.htm
防止目錄列表時顯示
IndexIgnore *
listen 8080
NameVirtualHost 10.122.89.106:8080
ServerAdmin [email protected]
DocumentRoot "/usr/local/www/apache22/data1/"
ServerName profile.test.com
RewriteEngine on
RewriteCond %{HTTP_HOST} ^folio.test.com [NC]
RewriteRule ^/(.*) http://profile.test.com/ [L]
更多的例子請參考:
http://www.cnblogs.com/huanghai/archive/2010/09/27/1836395.html
http://www.path8.net/tn/archives/1361