开启Apache mod_rewrite模块示例代码
启用mod_rewrite模块
在conf目录的httpd.conf文件中找到
loadmodule rewrite_module modules/mod_rewrite.so
将这一行前面的#去掉。
2.在要支持url rewirte的目录启用 options followsymlinks和allowoverride all
alias /php "c:/web/php/"
<directory "c:/web/php/">
options indexes followsymlinks
allowoverride all
order allow,deny
allow from all
</directory>
这样通过http://localhost:8080/php/访问时,/php/和其下面的子目录将支持url rewrite。
后记:php100.com
网上的很多文章并没有提到要使用 options followsymlinks,因为在httpd.conf中有
<directory />
options followsymlinks
allowoverride none
order deny,allow
deny from all
satisfy all
</directory>
这样如果你的网站配置成通过http://localhost:8080/来访问,就不会注意到options followsymlinks的影响,只需要将allowoverride none改为allowoverride all即可。而我习惯于在本机配置成http://localhost:8080/php/,忘了加options indexes followsymlinks就成功不了,会显示
forbidden
you don't have permission to access /php/f2blog/ on this server.
这样的错误。后来还是在apache文档中找到了原因
note: to enable the rewriting engine for per-directory configuration files you need to set ``rewriteengine on'' in these files and ``options followsymlinks'' must be enabled. if your administrator has disabled override of followsymlinks for a user's directory, then you cannot use the rewriting engine. this restriction is needed for security reasons.
实际上mod_rewrite是针对目录的,因此并不需要将httpd.conf中的所有allowoverride none改为allowoverride all,options也一样。
btw:看来首先是要看程序提供的文档,但是tomcat5.0.28的文档我几乎都看了,也没有看到说到底能不能通过service.bat在windows上安装成功服务。倒是看到n多人和我一样的疑问却没有答案,嗯,我当然知道通过tomcatxx.exe能安装成功tomcat服务,看来只有这一条路了。
如对本文有疑问,
点击进行留言回复!!
相关文章:
-
-
-
-
为Nginx动态添加模块的方法
写在前面很多时候,我们根据当时的项目情况和业务需求安装完nginx后,后续随着业务的发展,往往会给安装好的nginx添加其他的功能模块。在为nginx添加功能模...
[阅读全文]
-
-
-
-
-
UOS arm换源
清华源mv/etc/apt/sources.list /etc/apt/sources.list.bak备份原始...
[阅读全文]
-
-
IT基础与云计算
软路由器(IPtable)iptable是Linux上常用的防火墙软件。负载均衡负载均衡是网络基础构架的关键组件...
[阅读全文]
网友评论