php URL rewrite路径重写的实例介绍
2013-05-03 06:41
477 查看
发布:thatboy 来源:Net 【大 中 小】
为大家介绍一个php url rewrite路径重写的例子,有需要的朋友,可以参考下。
本文原始链接:http://www.jbxue.com/article/7392.html
一、文件 test.php
复制代码 代码示例:
<?php
$id=$_GET["id"];
echo $id;
?>
首先 apache文件里
打开Apache配置文件httpd.conf,找到如下:#LoadModule rewrite_module modules/mod_rewrite.so
开启rewrite,去点前面"#"
二、重载Allowoverride
查找apache配置文件找到如下:
复制代码 代码示例:
<Directory />
Options FollowSymLinks
AllowOverride None
</Directory>
将AllowOverride None 改为 AllowOverride All
在htaccess中暂时了解到三种url重定义
复制代码 代码示例:
<IFMODULE mod_rewrite.c>
RewriteEngine On
#RewriteBase / (若文件在根目录下不必定义)
#RewriteRule ^t_(.*).html$ test.php?id=$1 [NC](打开test.php以t_id.html 比如 t_2.html 页面输出 id=2)
RewriteRule ^([0-9]+)$ test.php?id=$1 [NC](直接输入id 比如 localhost/test/2 页面输出 id=2)
RewriteRule ^index.html$ index.php [NC](直接输入index.html可打开index.php这个页面)
</IFMODULE>
您可能感兴趣的文章:
php 伪静态(url重写)的写法
为大家介绍一个php url rewrite路径重写的例子,有需要的朋友,可以参考下。
本文原始链接:http://www.jbxue.com/article/7392.html
一、文件 test.php
复制代码 代码示例:
<?php
$id=$_GET["id"];
echo $id;
?>
首先 apache文件里
打开Apache配置文件httpd.conf,找到如下:#LoadModule rewrite_module modules/mod_rewrite.so
开启rewrite,去点前面"#"
二、重载Allowoverride
查找apache配置文件找到如下:
复制代码 代码示例:
<Directory />
Options FollowSymLinks
AllowOverride None
</Directory>
将AllowOverride None 改为 AllowOverride All
在htaccess中暂时了解到三种url重定义
复制代码 代码示例:
<IFMODULE mod_rewrite.c>
RewriteEngine On
#RewriteBase / (若文件在根目录下不必定义)
#RewriteRule ^t_(.*).html$ test.php?id=$1 [NC](打开test.php以t_id.html 比如 t_2.html 页面输出 id=2)
RewriteRule ^([0-9]+)$ test.php?id=$1 [NC](直接输入id 比如 localhost/test/2 页面输出 id=2)
RewriteRule ^index.html$ index.php [NC](直接输入index.html可打开index.php这个页面)
</IFMODULE>
您可能感兴趣的文章:
php 伪静态(url重写)的写法
相关文章推荐
- php URL 路径重写 rewrite
- php 伪静态 (url rewrite mod_rewrite 重写) 本地APACHE支持urlrewrite 本地APACHE支持.htaccess 【转】
- PHP操作Memcache实例介绍
- php中常用的正则表达式的介绍及应用实例代码
- php中的路径问题与set_include_path使用介绍
- Log4j2介绍和特性实例(六)--配置文件不在默认路径下的加载
- 实例介绍:php中$_SERVER[PHP_SELF]、$_SERVER[SCRIPT_NAME]、$_SERVER[REQUEST_URI]之间区别
- PHP设计模式之观察者模式(Observer)详细介绍和代码实例
- 网页实例:详细介绍用PHP来编写网页记数器
- HTML5 Canvas――用路径描画线条实例介绍
- php生成txt文件实例代码介绍
- PHP设计模式之观察者模式(Observer)详细介绍和代码实例
- PHP ignore_user_abort函数详细介绍和使用实例
- php中常用的正则表达式的介绍及应用实例代码
- php开发设计介绍及实例介绍(二)前端控制器分发、会话技术cookie
- php disk_free_space与disk_total_space实例介绍
- php数据库抽象层之PDO介绍及简单实例
- PHP的curl实现get,post和cookie(实例介绍)
- PHP实现的迪科斯彻(Dijkstra)最短路径算法实例
- php 重写分页器 CLinkPager的实例