apche 开启rewrite 重写url实现伪静态
2013-05-30 14:48
381 查看
1.首先开启apache的rewrite模块
LoadModule rewrite_module modules/mod_rewrite.so
2.开启支持虚拟主机并配置一个虚拟主机
# Virtual hosts
Include conf/extra/httpd-vhosts.conf
<VirtualHost *:80>
DocumentRoot "d:/www2"
ServerName test.com
<Directory "d:/www2">
Options Indexes FollowSymLinks
AllowOverride all
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
3.在C盘windows--system32-drivers-etc 找到hosts文件
配置:127.0.0.1 test.com
4.在项目的目录下新建 .htaccess 文件 内容如下:
<IfModule mod_rewrite.c>
RewriteEngine on #开启重写
RewriteRule ^news-id-(\d+)\.html news.php?id=$1 #重写的正则规则 要访问的真实地址及参数传递
</IfModule>
5.重启apache
访问url: test.com/news-id-123456.html------->test.com/news.php?id=123456
LoadModule rewrite_module modules/mod_rewrite.so
2.开启支持虚拟主机并配置一个虚拟主机
# Virtual hosts
Include conf/extra/httpd-vhosts.conf
<VirtualHost *:80>
DocumentRoot "d:/www2"
ServerName test.com
<Directory "d:/www2">
Options Indexes FollowSymLinks
AllowOverride all
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
3.在C盘windows--system32-drivers-etc 找到hosts文件
配置:127.0.0.1 test.com
4.在项目的目录下新建 .htaccess 文件 内容如下:
<IfModule mod_rewrite.c>
RewriteEngine on #开启重写
RewriteRule ^news-id-(\d+)\.html news.php?id=$1 #重写的正则规则 要访问的真实地址及参数传递
</IfModule>
5.重启apache
访问url: test.com/news-id-123456.html------->test.com/news.php?id=123456
相关文章推荐
- Nginx服务器下使用rewrite重写url以实现伪静态的示例
- ISAPI Rewrite 实现简单url重写、二级域名重写
- ASP.NET 如何实现伪静态 url重写路由功能
- WAMP SERVER开启rewrite伪静态重写模块
- 利用URLRewriter重写url 实现伪静态
- ASP.NET URL Rewrite. URL重写(静态页和伪静态共存)
- Apache Rewrite模块重写功能开启及检测实现
- IIRF(Ionics Isapi Rewrite Filt er)实现在IIS 5/6上重写Url
- Apache利用.htaccess文件重写URL隐藏入口,模块名,实现伪静态
- php为静态实现之URL重写
- IIRF(Ionics Isapi Rewrite Filt er)实现在IIS 5/6上重写Url
- IIRF(Ionics Isapi Rewrite Filt er)实现在IIS 5/6上重写Url
- 用 UrlRewriteFilter 实现 URL 重写
- 在用Urlrewrite.dll实现伪静态时,真实静态无法访问!
- 利用URLRewriter重写url地址-实现伪静态
- 用 UrlRewriteFilter 实现 URL 重写
- URL重写之ISAPI_Rewrite的应用
- urlRewriteFilter来实现url的美化
- Nginx静态资源服务器开启https配置及http rewrite到https
- nginx、TP框架实现兼容pathinfo和rewrite两种url访问方式