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配置:
支持 httpd.conf 配置和目录 .htaccess 配置 启用 rewrite # LoadModule rewrite_module modules/mod_rewrite.so 去除前面的 # LoadModule rewrite_module modules/mod_rewrite.so 启用 .htaccess AllowOverride None 修改为: AllowOverride All------------------------------------------------------------------------------ 让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 * 2.一 个简单的例子 将输入 folio.test.com 的域名时跳转到profile.test.comlisten 8080NameVirtualHost 10.122.89.106:8080 ServerAdmin webmaster@colorme.com.cnDocumentRoot "/usr/local/www/apache22/data1/"ServerName profile.test.comRewriteEngine on RewriteCond %{HTTP_HOST} ^folio.test.com [NC]RewriteRule ^/(.*) http://profile.test.com/ [L]
更多的例子请参考:
http://www.cnblogs.com/huanghai/archive/2010/09/27/1836395.htmlhttp://www.path8.net/tn/archives/1361