PHP头条
热点:

关于PHP伪静态Rewrite设置,php伪rewrite


Rewirte主要的功能就是实现URL的跳转和隐藏真实地址,基于Perl语言的正则 表达式规范。平时帮助我们实现拟静态,拟目录,域名跳转,防止盗链等   一、Apache配置:   1、支持httpd.conf 配置 2、支持目录 .htaccess配置(一种"分布式配置"文件针对虚拟空间,空间商不让修改Apache配置文件)   启用Rewrite(httpd.conf) (有时候Options Indexes FollowSymLinks会出问题,只需要配置Options all即可) LoadModule rewrite_module modules/mod_rewrite.so   启用.htaccess AllowOverride None    修改为:AllowOverride All   二、mod_rewrite 规则: 例如: RewriteEngine on                           ->启动rewrite引擎   RewriteRule ^/test([0-9]*).html$ /test.php?id=$1    ->指访问test加任意字段.html都能跳转到test.php       正则匹配的字段存放在虚拟内存匹配$1
    三、mod_rewrite规则修正符     1) R 强制外部重定向 2) F 禁用URL,返回403HTTP状态码。 3) G 强制URL为GONE,返回410HTTP状态码。 4) P 强制使用代理转发。 5) L 表明当前规则是最后一条规则,停止分析以后规则的重写。 6) N 重新从第一条规则开始运行重写过程。 7) C 与下一条规则关联   如果规则匹配则正常处理,以下修正符无效   8) T=MIME-type(force MIME type) 强制MIME类型 9) NS  只用于不是内部子请求 10) NC 不区分大小写 11) QSA 追加请求字符串 12) NE 不在输出转义特殊字符   \%3d$1  等价于 =$1     例如: RewriteRule ^/new([0-9]*)/$ /new.php?id=$1 [R]     简单小范例:
RewriteEngine on
RewriteRule ^/in(.*).html$ /index.php

轻松实现~

     

apache配置Rewrite的问题 PHP|伪静态|RewriteRule

<IfModule rewrite_module>
RewriteEngine On
RewriteRule ^(.*)/classlist/(.*)$ $1/class_list.php?type=$2
</IfModule>
 

虚拟主机是Linux系统,网站程序的运行环境是php+mysql,怎设置伪静态??

你好,这个得根据你的网站程序和WEB服务器环境来设置伪静态的,比如你用LNMP环境,而用的PHP程序是DZ2.5那么你的伪静态就可以为:
rewrite ^([^\.]*)/topic-(.+)\.html$ $1/portal.php?mod=topic&topic=$2last;
rewrite ^([^\.]*)/article-([0-9]+)-([0-9]+)\.html$ $1/portal.php?mod=view&aid=$2&page=$3 last;
rewrite ^([^\.]*)/forum-(\w+)-([0-9]+)\.html$ $1/forum.php?mod=forumdisplay&fid=$2&page=$3 last;
rewrite ^([^\.]*)/thread-([0-9]+)-([0-9]+)-([0-9]+)\.html$ $1/forum.php?mod=viewthread&tid=$2&extra=page%3D$4&page=$3 last;
rewrite ^([^\.]*)/group-([0-9]+)-([0-9]+)\.html$ $1/forum.php?mod=group&fid=$2&page=$3 last;
rewrite ^([^\.]*)/space-(username|uid)-(.+)\.html$ $1/home.php?mod=space&$2=$3 last;
rewrite ^([^\.]*)/blog-([0-9]+)-([0-9]+)\.html$ $1/home.php?mod=space&uid=$2&do=blog&id=$3 last;
rewrite ^([^\.]*)/(fid|tid)-([0-9]+)\.html$ $1/index.php?action=$2&value=$3 last;
rewrite ^([^\.]*)/([a-z]+[a-z0-9_]*)-([a-z0-9_\-]+)\.html$ $1/plugin.php?id=$2:$3 last;
if (!-e $request_filename) {
return 404;
}

有问题可以+Q+群222802357找群主吧。
 

www.phpzy.comtrue/php/12953.htmlTechArticle关于PHP伪静态Rewrite设置,php伪rewrite Rewirte主要的功能就是实现 URL的跳转和隐藏真实地址 ,基于Perl语言的正则表达式规范。平时帮助我们实现拟静态,拟目录,域名跳转,防止盗链等...

相关文章

    暂无相关文章
相关频道:

PHP之友评论

今天推荐