加载Rewrite模块:
在conf目录下httpd.conf中找到
LoadModule rewrite_module modules/mod_rewrite.so
这句,去掉前边的注释符号“#”,或添加这句。
允许在任何目录中使用“.htaccess”文件,将“AllowOverride”改成“All”(默认为“None”):
# AllowOverride controls what directives may be placed in .htaccess files.
# It can be “All”, “None”, or any combination of the keywords:
# Options FileInfo AuthConfig Limit
#
AllowOverride All
在Windows系统下不能直接建立“.htaccess”文件,可以在命令行下使用“echo a> .htaccess”建立,然后使用记事本编辑。
将下面的代码保存为.htaccess文件,上传到网站任一目录下.
访问该目录下的任意内容,如果浏览器跳转到了我的博客首页,恭喜你REWRITE 开启成功!
RewriteEngine on
RewriteBase /
RewriteRule .*$ http://blog.sina.com/bmd360