php URL 路径重写 rewrite
2013-05-31 08:06
387 查看
假如这里有一个 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
$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>
相关文章推荐
- Nginx、PCRE和中文URL(UTF8编码)rewrite路径重写匹配问题
- Nginx、PCRE和中文URL(UTF8编码)rewrite路径重写匹配问题
- Nginx、PCRE和中文URL(UTF8编码)rewrite路径重写匹配问题
- Apache & nginx 的地址重写 url_rewrite,省略 index.php
- [tp3.2.1]开启URL(重写模式),省略URL中的index.php
- .NET4.0下web应用程序用UrlRewriter.dll重写无后缀路径
- Windows10中的IIS10安装php manager和IIS URL Rewrite 2.0组件的方法
- PHP获取当前url路径的函数及服务器变量:$_SERVER['.....']
- PHP获取当前url路径的函数及服务器变灿
- IIRF(Ionic's Isapi Rewrite Filt er)入门,在IIS上重写Url
- PHP获取当前url路径的函数及服务器变量:$_SERVER["QUERY_STRING"],$_SERVER["REQUEST_URI"],$_SERVER["SCRIPT_NAME"],$_SER
- 实现PHP伪静态的方式之URL重写
- 2017-06-21 在web.xml中使用UrlRewriteFilter来对url进行重写
- Nginx中rewrite实现二级域名、三级域名、泛域名、路径的重写
- linux php下Ajax请求时URL路径出现重复
- apache 配置rewrite模块,URL中隐藏index.php
- 对php工程的url进行重写(去掉.php文件后缀)
- Apache VirtualHost 虚拟主机 ProxyPass 反向代理 RewriteEngine url 重写
- ThinkPHP 利用.htaccess文件的 Rewrite 规则隐藏URL中的 index.php
- URL 重写 only for ASP.NET 2.0: UrlRewritingNet.UrlRewrite