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>
在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>
相关文章推荐
- Apache zend框架的程序 虚拟机设置 ------windows下
- Apache中设置虚拟主机的URL重写功能
- Apache中设置虚拟主机的URL重写功能
- Windows本地Apache设置虚拟机
- Apache中设置虚拟主机的URL重写功能
- Apache Hadoop集群设置示例(带虚拟机)
- 在Apache设置虚拟机
- Centos7安装apache2.4.6,Apache调优及设置虚拟机
- apache虚拟机的开启iis apache共存 apache 的设置(报错 找不到 Not found)
- Windows环境下PHP多虚拟机设置、Apache+php+mysql
- 虚拟机网络连接方式和网络设置
- java 虚拟机参数设置堆大小的分配可能导致内存暴增
- windows7和虚拟机的共享设置
- Apache相关安全设置
- 防恶意解析,禁止用IP访问网站的Apache设置
- Apache设置目录禁止访问
- www(apache)服务器的基本设置
- Linux系列:Ubuntu虚拟机设置固定IP上网(配置IP、网关、DNS、防止resolv.conf被重写)
- Apache的KeepAlive设置与优化
- centos7 虚拟机桥接设置