win2003 server 下 配置 apache 的rewrite

When I try to setup PHP and Apache in my notebook, I try to enable the .htaccess setting in apache's httpd.conf. After I tried for a few hours (YES, a few hours) at my notebook and google-ing on the internet, finally I found the complete solution.

I record the steps here so that it can help those who want to enable .htaccess and url rewriting in Apache for Windows and also for my own reference in future.

1. Make sure you have setup apache and php correctly. Make sure that you can run php scripts without any problem.

2. Use notepad to open httpd.conf config file. Make use the line "LoadModule rewrite_module modules/mod_rewrite.so" is un-commented.

3. Under "<directory XXX></directory>" section, change the line "AllowOverride None" to "AllowOverride All".

4. Change the line "AccessFileName .htaccess" to "AccessFileName htaccess". This is because in Windows, we can't have a file with filename that starts with a dot.

5. Save the changed file and restart Apache Windows Service. You can then use the file htaccess to process your url rewritting.


简单翻译一下就是:

1.去掉 LoadModule rewrite_module modules/mod_rewrite.so 前的# (apache 2.2)

2.修改 <directory XXX></directory> 中的 AllowOverride None 为 AllowOverride All

3.如果 httpd.conf (在apache的安装目录里conf文件夹) 中 有 AccessFileName .htaccess 这行 就修改为 AccessFileName htaccess, 并把网站目录里的 .htaccess修改为 htaccess, 不需要文件后缀,因为windows不支持以 .开头的文件。如果httpd.conf里面有没有这行,在 <directory XXX></directory> 后面加上 这行 AccessFileName htaccess 就可以了。

4.保存,重启apache就可以了。然后正确编写 url rewrite的rule.


一直都在用linux下的apache,刚接触 win2003下的apache 重写,网上有很多文章,都提到了前2条,但是对第3条没有涉及,这一条也很关键。以备后用。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值