1. /search.php?keyword=mp3&catid=catid     重写成 mp3.xx.com (keyword值只有字母和数字)
2. /shop.php?q=%E6%9D%A8%E6%AC%A35201314   重写成 /selloffer/%E6%9D%A8%E6%AC%A35201314.html3. /list.php?catid=c1&page=2&sort=s1&keyword=%E5%A4%A7
   重写成
   /offerlist/c1/2_s1_%E5%A4%A7.html4. /list.php?catid=12                      重写成 12.xx.com (此处catid值只有数字)
5. /list.php?keyword=%E5%A4%A7&catid=catid 重写成 /offerlist/%E5%A4%A7.html6. /list.php?keyword=%E5%A4%A7&start_price=100&end_price=1000&catid=c1
   重写成
   /offerlist/%E5%A4%A7_100_1000_c1.html7. /list.php?keyword=%E5%A4%A7&start_credit=1gold&end_credit=5gold&catid=c1 [L]
   重写成
   /offerlist/%E5%A4%A7_1gold_5gold_c1.html8. /good.php?aid=78945612                  重写成 /offerdetail/78945612.html   PS:
2.x版本的httpd.ini;有几条对同一个list.php页面写规则,要不能干扰,有两处要实现二级域名,也不能有干扰,不能第一条管用第二条就不管用了。 实现二级域名的泛解析和绑定都弄好了,这个不用管。

解决方案 »

  1.   

    RewriteRule ^(/w).(/w).com$  /search.php?keyword=$1&catid=$2 
    楼主照着这个例子 看看吧
      

  2.   

    WEB SERVER是APACHE吗?URL重写指南- Apache HTTP服务器
      

  3.   

    APACHE通过URL重写伪静态一.Apache设置
    独立主机用户
    Apache 基本配置:
    首先确定您使用的 Apache 版本,及是否加载了 mod_Rewrite 模块。
    Apache 1.x 的用户请检查 conf/httpd.conf 中是否存在如下两段代码:
    LoadModule Rewrite_module libexec/mod_Rewrite.so
    AddModule mod_Rewrite.c
    Apache 2.x 的用户请检查 conf/httpd.conf 中是否存在如下一段代码:
    LoadModule Rewrite_module modules/mod_Rewrite.so
    如果没有安装 mod_Rewrite,您可以重新编译 Apache,并在原有 configure 的内容中加入 --enable-Rewrite=shared
    注:如果前面有#,将其去掉。
    方法一:通过配置Apache配置文件httpd.conf实现URL重写
    在配置文件(通常就是 conf/httpd.conf)中加入如下代码。
    <IfModule mod_Rewrite.c>
    RewriteEngine On
    RewriteRule ^(.*)/archiver/((fid|tid)-[\w\-]+\.html)$ $1/archiver/index.php?$2
    RewriteRule ^(.*)/forum-([0-9]+)-([0-9]+)\.html$ $1/forumdisplay.php?fid=$2&page=$3
    RewriteRule ^(.*)/thread-([0-9]+)-([0-9]+)-([0-9]+)\.html$ $1/viewthread.php?tid=$2&extra=page\%3D$4&page=$3
    RewriteRule ^(.*)/space-(username|uid)-(.+)\.html$ $1/space.php?$2=$3
    RewriteRule ^(.*)/tag-(.+)\.html$ $1/tag.php?name=$2
    </IfModule>
    注:此时请务必注意,如果网站使用通过虚拟主机来定义,请务必加到虚拟主机配置,即 <VirtualHost> 中去,如果加在虚拟主机配置外部将可能无法使用,改好后将 Apache 重启。
    方法二:通过在根目录中的跨越配置文件.htaccess实现URL重写
    1.
    配置apache支持对 .htaccess 文件的解析
    查找:
    <Directory />
    Options FollowSymLinks
    AllowOverride None
    </Directory>
    修改为:
    <Directory />
    Options FollowSymLinks
    AllowOverride All
    </Directory>
    man对AllowOverride 的解释:
    AllowOverride controls what directives may be placed in .htaccess files.
    It can be "All", "None", or any combination of the keywords:
    Options FileInfo AuthConfig Limit
    就是说,将None改为All,.htaccess文件才能被支持!
    2. 创建.htaccess文件Win32 系统下,无法直接建立 .htaccess 文件,您可以从其他系统中拷贝一份,或者在 Discuz.net 技术支持栏目中下载此文件。(附件中可下载)
    3. 编辑.htaccess文件
    # 将 RewriteEngine 模式打开
    RewriteEngine On
    # .htaccess文件路径,如果在系统跟目录则为RewriteBase /,如果在根目录下的其他文件夹,如在根目录下的test文件夹,则为RewriteBase /test,此处将.htaccess放在根目录下。
    RewriteBase /discuz
    # Rewrite 系统规则请勿修改
    RewriteRule ^archiver/((fid|tid)-[\w\-]+\.html)$ archiver/index.php?$1
    RewriteRule ^forum-([0-9]+)-([0-9]+)\.html$ forumdisplay.php?fid=$1&page=$2
    RewriteRule ^thread-([0-9]+)-([0-9]+)-([0-9]+)\.html$ viewthread.php?tid=$1&extra=page\%3D$3&page=$2
    RewriteRule ^space-(username|uid)-(.+)\.html$ space.php?$1=$2
    RewriteRule ^tag-(.+)\.html$ tag.php?name=$1
    租用空间用户(多是虚拟主机用户)
    1. 首先咨询您的空间服务商,空间是否支持 Rewrite 以及是否支持对站点目录中 .htaccess 的文件解析,否则即便按照下面的方法设置好了,也无法使用。
    2. 创建.htaccess文件Win32 系统下,无法直接建立 .htaccess 文件,您可以从其他系统中拷贝一份,或者在 Discuz.net 技术支持栏目中下载此文件。
    3. 编辑.htaccess文件
    # 将 RewriteEngine 模式打开
    RewriteEngine On
    # .htaccess文件路径,如果在系统跟目录则为RewriteBase /,如果在根目录下的其他文件夹,如在根目录下的test文件夹,则为RewriteBase /test,此处将.htaccess放在根目录下。
    RewriteBase /discuz
    # Rewrite 系统规则请勿修改
    RewriteRule ^archiver/((fid|tid)-[\w\-]+\.html)$ archiver/index.php?$1
    RewriteRule ^forum-([0-9]+)-([0-9]+)\.html$ forumdisplay.php?fid=$1&page=$2
    RewriteRule ^thread-([0-9]+)-([0-9]+)-([0-9]+)\.html$ viewthread.php?tid=$1&extra=page\%3D$3&page=$2
    RewriteRule ^space-(username|uid)-(.+)\.html$ space.php?$1=$2
    RewriteRule ^tag-(.+)\.html$ tag.php?name=$1
    二.Rewrite 规则
    上面无论是在apache中设置的:
    <IfModule mod_Rewrite.c>
    RewriteEngine On
    RewriteRule ^(.*)/archiver/((fid|tid)-[\w\-]+\.html)$ $1/archiver/index.php?$2
    RewriteRule ^(.*)/forum-([0-9]+)-([0-9]+)\.html$ $1/forumdisplay.php?fid=$2&page=$3
    RewriteRule ^(.*)/thread-([0-9]+)-([0-9]+)-([0-9]+)\.html$ $1/viewthread.php?tid=$2&extra=page\%3D$4&page=$3
    RewriteRule ^(.*)/space-(username|uid)-(.+)\.html$ $1/space.php?$2=$3
    RewriteRule ^(.*)/tag-(.+)\.html$ $1/tag.php?name=$2
    </IfModule>
    还在是文件.htaccess中添加的:
    # 将 RewriteEngine 模式打开
    RewriteEngine On
    # .htaccess文件路径,如果在系统跟目录则为RewriteBase /,如果在根目录下的其他文件夹,如在根目录下的test文件夹,则为RewriteBase /test,此处将.htaccess放在根目录下。
    RewriteBase /discuz
    # Rewrite 系统规则请勿修改
    RewriteRule ^archiver/((fid|tid)-[\w\-]+\.html)$ archiver/index.php?$1
    RewriteRule ^forum-([0-9]+)-([0-9]+)\.html$ forumdisplay.php?fid=$1&page=$2
    RewriteRule ^thread-([0-9]+)-([0-9]+)-([0-9]+)\.html$ viewthread.php?tid=$1&extra=page\%3D$3&page=$2
    RewriteRule ^space-(username|uid)-(.+)\.html$ space.php?$1=$2
    RewriteRule ^tag-(.+)\.html$ tag.php?name=$1
    其中都指明了URL重写规则。
    请看:RewriteRule ^forum-([0-9]+)-([0-9]+)\.html$ forumdisplay.php?fid=$1&page=$2
    这句说明了URL为forumdisplay.php?fid=$1&page=$2可以写成forum-([0-9]+)-([0-9]+)\.html这种模式。
    如:访问http://localhost/ forumdisplay.php?fid=1&page=2与访问http://localhost/ forum-1-2.html的效果是一样的!
    注:这些规则是可以自己写正则表达式随意更改的。根据自己需要的格式。来定制URL重写规则。
    参考资料:
    http://faq.comsenz.com/viewnews-12
    http://www.eygle.com/digest/2005/09/apache_oeoeooaeuooa_rewrite.html
      

  4.   


    win 2003  isapi_rewrite 
      

  5.   

    # Block external access to the httpd.ini and httpd.parse.errors files
    RewriteRule /httpd(?:.ini|.parse.errors).* / [F,I,O]
    # Block external access to the Helper ISAPI Extension
    RewriteRule .*.isrwhlp / [F,I,O]
    #二级域名RewriteCond Host: (?!tao|www)([^.]+).xxx.cn
    RewriteRule ([^.]+) /search\.php\?keyword=$1&catid=catid