URL Rewrite的设置方法

yipeiwu_com6年前PHP代码库
URL Rewrite需要服务器的支持!在启用此设置之前,请确保服务器上已作出了正确的设置,设置方法请参看下边的“Apache下的设置方法”和“IIS下的设置方法”!
Apache下的设置方法
复制代码 代码如下:

打开 Apache 的配置文件 httpd.conf 。 
将#LoadModule rewrite_module modules/mod_rewrite前面的#去掉 
在 httpd.conf中添加:
<IfModule mod_rewrite.c>
    RewriteEngine On
    #RewriteCond %{ENV:SCRIPT_URL} (?:index|dispbbs)[-0-9]+\.html
    RewriteRule ^(.*?(?:index|dispbbs))-([-0-9]+)\.html$ $1.php?__is_apache_rewrite=1&__rewrite_arg=$2
</IfModule>

要实现asp帖子URL到php帖子的映射,在 第三步的<IfModule mod_rewrite.c>和</IfModule>之间添加:
    RewriteMap tolowercase int:tolower
    RewriteCond %{QUERY_STRING} (?:boardid|page|id|replyid|star|skin)\=\d+ [NC]
    RewriteRule ^(.*(?:index|dispbbs))\.asp$ $1.php?${tolowercase:%{QUERY_STRING}}&__is_apache_rewrite=1

保存httpd.conf并重启Apache。

相关文章

用php过滤危险html代码的函数

#用户发布的html,过滤危险代码  function uh($str)  {  $farr = array(  "...

PHP Try-catch 语句使用技巧

PHP Try-catch 语句 为了进一步处理异常,我们需要使用try-catch语句----包括Try语句和至少一个的catch语句。任何调用 可能抛出异常的方法的代码都应该使用tr...

解析php函数method_exists()与is_callable()的区别

php函数method_exists() 与is_callable()的区别在哪?在php面相对象设计过程中,往往我们需要在调用某一个方法是否属于某一个类的时候做出判断,常用的方法有 m...

常用PHP数组排序函数归纳

常用PHP数组排序函数归纳

数组排序:数组中的元素能够以字母或数字顺序进行升序或降序排序。 常用的PHP数组排序函数  •sort() - 以升序对数组排序  •rso...

PHP简单字符串过滤方法示例

PHP简单字符串过滤方法示例

本文实例讲述了PHP简单字符串过滤方法。分享给大家供大家参考,具体如下: <!DOCTYPE html> <html lang="zh-cn"> <he...