documentroot e:/daima/htdocs/virtual
servername www.lhb.com
#directory节点指定该目录下的文件,图片的访问权限
#设置虚拟主机的错误页面,欢迎页面
order allow,deny
allow from all
#是否列出文件目录(none不显示indexes显示目录)
options indexes
#设置错误页面
errordocument 404 /error.html
#设置首页面
directoryindex index.html
#allowoverride all
#配置rewrite
rewriteengine on
rewriterule aaa.html news.php
去掉rewriteengine on
rewriterule aaa.html news.php错误页面,首页面均能正确显示,带入那2行代码,在浏览器输入www.lhb.com/aaa.html则报错:you don't have permission to access / on this server.
回复讨论(解决方案) 用的apache?为什么不用.htaccess文件呢?
写apache配置文件里多麻烦,有改动还得重启服务。
用的apache?为什么不用.htaccess文件呢?
写apache配置文件里多麻烦,有改动还得重启服务。
用.htaccess也不行啊
.htaccess代码:
options followsymlinks
rewriteengine on
rewriterule rewriterule aaa.html news.php
httpd-vhosts.conf代码
documentroot e:/daima/htdocs/virtual
servername www.lhb.com
#directory节点指定该目录下的文件,图片的访问权限
#设置虚拟主机的错误页面,欢迎页面
order allow,deny
allow from all
#是否列出文件目录(none不显示indexes显示目录)
options indexes
#设置错误页面
errordocument 404 /error.html
#设置首页面
directoryindex index.html
allowoverride all
#配置rewrite
首页面 错误页面能够访问 访问http://www.lhb.com/aaa.html就是aaa.html的内容也不能实现伪静态
rewriteengine onrewriterule ^aaa\.html news.php [nc]
rewriteengine onrewriterule ^aaa\.html news.php [nc]
rewriteengine onrewriterule ^aaa\.html news.php [nc]
按照你这种设置,http://www.lhb.com/aaa.html也会报错:you don't have permission to access / on this server. 虽然不知道为啥,但把配置文件httpd-vhosts.conf里的options none选项去掉就可以实现伪静态了
