Blogger Information
Blog 56
fans 7
comment 11
visits 222475
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
PHP实现伪静态 RewriteRule ^(.*)$ index.php/$1 [QSA,PT,L] 是什么意思?
樂成的开发笔记
Original
3090 people have browsed it

PHP实现伪静态


实例

<IfModule mod_rewrite.c>
Options +FollowSymlinks
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php/$1 [QSA,PT,L]
</IfModule>

运行实例 »

点击 "运行实例" 按钮查看在线实例

1、排除一些条件,必须两个条件都满足后才重定向到index.php
//如果你访问的文件不等于目录

RewriteCond %{REQUEST_FILENAME} !-d

//如果你访问不是文件,比如你可能访问的JPEG等图片文件

RewriteCond %{REQUEST_FILENAME} !-f

2、^(.*)$ 匹配所有的路径映射到入口文件 index.php/$1

3、标签 [QSA,PT,L] QSA:表示保留参数如get传值?xxx==xx...; PT:再把这个URL交给Apache处理;L:作为最后一条;
PT和L可加可不加。


举个例子
RewriteRule list/([1-9]+[0-9]*).html$ list.php?pid=$1 [QSA]
原链接:http://www.xxx.com/list.php?pid=1
伪静态:http://www.xxx.com/list/1.html

[QSA] 表示保留参数如get传值?xxx==xx...;

原链接:http://www.xxx.com/list.php?pid=1&key=关键词
伪静态:http://www.xxx.com/list/1.html?key=关键词

Statement of this Website
The copyright of this blog article belongs to the blogger. Please specify the address when reprinting! If there is any infringement or violation of the law, please contact admin@php.cn Report processing!
All comments Speak rationally on civilized internet, please comply with News Comment Service Agreement
0 comments
Author's latest blog post