您的位置:首页 > 运维架构 > Apache

Apache下url重写,虚拟机设置

2012-02-21 19:23 253 查看
1.http://www.linuxsir.org/main/node/293

在httpd里打开mod_rewrite.so模块

2.在需要重写的网站目录下建立.htaccess文件

3.ErrorDocument 404 /notfound.html

<IfModule mod_rewrite.c>

RewriteEngine on

RewriteBase /

RewriteCond %{REQUEST_FILENAME} !-f //判断文件是否存在,不存在才执行重写

RewriteCond %{REQUEST_FILENAME} !-d //判断目录是否存在,不存在才执行重写

RewriteRule ^(.*)[.]html$ $1.php

</IfModule>

记得需要取用的字符串用()括起来,然后后面才能$1来取用

正则参考http://deerchao.net/tutorials/regex/regex.htm

NameVirtualHost *:80

<VirtualHost *:80>

DocumentRoot "D:/wamp/www/"

ServerName localhost

ServerAlias localhost

</VirtualHost>

<VirtualHost *:80>

DocumentRoot "D:/wamp/www/test/"

ServerName test

ServerAlias test

</VirtualHost>
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: