当前位置:首页 > 建站 > 正文内容

Zblog/Nginx给目录添加反斜杠的伪静态规则方法

innov1年前 (2024-01-19)建站1660

非zbogPHP程序的网站只复制绿色加粗部分代码就行。

Apache .htaccess

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^([^\.]+[^/])$ /$1/ [L,R=301]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>

Nginx

if (!-f $request_filename){
    rewrite ^/([^\.]+[^/])$ http://$host/$1$2/ permanent;
}
if (-f $request_filename/index.html){
    rewrite (.*) $1/index.html break;
}
if (-f $request_filename/index.php){
    rewrite (.*) $1/index.php;
}
if (!-f $request_filename){
    rewrite (.*) /index.php;
}

IIS6+ISAPI Rewrite 2.X

[ISAPI_Rewrite]
RewriteRule /(?!zb_)([^\.]+[^/]) /$1/ [RP,L]
RewriteRule /default_([0-9]+)\.html /catalog\.asp\?page=$1
RewriteRule /category/(?!zb_)(.*)_([0-9]+)/ /catalog\.asp\?cate=$1&page=$2
RewriteRule /category/(?!zb_)(.*)/ /catalog\.asp\?cate=$1
RewriteRule /author-([0-9]+)_([0-9]+).html /catalog\.asp\?auth=$1&page=$2
RewriteRule /author-([0-9]+).html /catalog\.asp\?auth=$1
RewriteRule /tags-([0-9]+)_([0-9]+).html /catalog\.asp\?tags=$1&page=$2
RewriteRule /tags-([0-9]+).html /catalog\.asp\?tags=$1
RewriteRule /post/([0-9\-]+)_([0-9]+)/ /catalog\.asp\?date=$1&page=$2
RewriteRule /post/([0-9\-]+)/ /catalog\.asp\?date=$1
RewriteRule /post/(?!zb_)(.*)/ /view\.asp\?id=$1
RewriteRule /(?!zb_)(.*)/ /view\.asp\?id=$1

IIS6+ISAPI Rewrite 3.X

#ISAPI Rewrite 3
RewriteBase /
RewriteRule ^(?!zb_)([^\.]+[^/])$ /$1/ [NU,R=301]
RewriteRule ^default_([0-9]+)\.html$ /catalog.asp\?page=$1
RewriteRule ^category/(?!zb_)(.*)_([0-9]+)/$ /catalog.asp\?cate=$1&page=$2 [NU]
RewriteRule ^category/(?!zb_)(.*)/$ /catalog.asp\?cate=$1 [NU]
RewriteRule ^author-([0-9]+)_([0-9]+).html$ /catalog.asp\?auth=$1&page=$2 [NU]
RewriteRule ^author-([0-9]+).html$ /catalog.asp\?auth=$1 [NU]
RewriteRule ^tags-([0-9]+)_([0-9]+).html$ /catalog.asp\?tags=$1&page=$2 [NU]
RewriteRule ^tags-([0-9]+).html$ /catalog.asp\?tags=$1 [NU]
RewriteRule ^post/([0-9\-]+)_([0-9]+)/$ /catalog.asp\?date=$1&page=$2 [NU]
RewriteRule ^post/([0-9\-]+)/$ /catalog.asp\?date=$1 [NU]
RewriteRule ^post/(?!zb_)(.*)/$ /view.asp\?id=$1 [NU]
RewriteRule ^(?!zb_)(.*)/$ /view.asp\?id=$1 [NU]

IIS7、7.5、8+Url Rewrite

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
  <rewrite>
   <rules>
     <rule name="//" stopProcessing="true">
      <match url="^(?!zb_)[^\.]+[^/]$"/>
      <action type="Redirect" redirectType="Permanent" url="{R:0}/"/>
     </rule>
     <rule name="Imported Rule Default+Page" stopProcessing="true">
      <match url="^default_([0-9]+)\.html$" ignoreCase="false" />
      <action type="Rewrite" url="catalog.asp?page={R:1}" />
     </rule>
     <rule name="Imported Rule Category+Page" stopProcessing="true">
      <match url="^category-([0-9]+)_([0-9]+).html$" ignoreCase="false" />
      <action type="Rewrite" url="catalog.asp?cate={R:1}&page={R:2}" />
     </rule>
     <rule name="Imported Rule Category" stopProcessing="true">
      <match url="^category-([0-9]+).html$" ignoreCase="false" />
      <action type="Rewrite" url="catalog.asp?cate={R:1}" />
     </rule>
     <rule name="Imported Rule Author+Page" stopProcessing="true">
      <match url="^author-([0-9]+)_([0-9]+).html$" ignoreCase="false" />
      <action type="Rewrite" url="catalog.asp?auth={R:1}&page={R:2}" />
     </rule>
     <rule name="Imported Rule Author" stopProcessing="true">
      <match url="^author-([0-9]+).html$" ignoreCase="false" />
      <action type="Rewrite" url="catalog.asp?auth={R:1}" />
     </rule>
     <rule name="Imported Rule Tags+Page" stopProcessing="true">
      <match url="^tags-([0-9]+)_([0-9]+).html$" ignoreCase="false" />
      <action type="Rewrite" url="catalog.asp?tags={R:1}&page={R:2}" />
     </rule>
     <rule name="Imported Rule Tags" stopProcessing="true">
      <match url="^tags-([0-9]+).html$" ignoreCase="false" />
      <action type="Rewrite" url="catalog.asp?tags={R:1}" />
     </rule>
     <rule name="Imported Rule Date+Page" stopProcessing="true">
      <match url="^date-([0-9\-]+)_([0-9]+).html$" ignoreCase="false" />
      <action type="Rewrite" url="catalog.asp?date={R:1}&page={R:2}" />
     </rule>
     <rule name="Imported Rule Date" stopProcessing="true">
      <match url="^date-([0-9\-]+).html$" ignoreCase="false" />
      <action type="Rewrite" url="catalog.asp?date={R:1}" />
     </rule>
     <rule name="Imported Rule Article" stopProcessing="true">
      <match url="^post/(?!zb_)(.*).html$" ignoreCase="false" />
      <action type="Rewrite" url="view.asp?id={R:1}" />
     </rule>
     <rule name="Imported Rule Page" stopProcessing="true">
      <match url="^(?!zb_)(.*).html$" ignoreCase="false" />
      <action type="Rewrite" url="view.asp?id={R:1}" />
     </rule>
   </rules>
  </rewrite>
  </system.webServer>
</configuration>

扫描二维码推送至手机访问。

版权声明:本文由知新日笺发布,如需转载请注明出处。

本文链接:https://innovdn.cn/post/544.html

分享给朋友:

“Zblog/Nginx给目录添加反斜杠的伪静态规则方法” 的相关文章

zblogphp后台密码忘记了怎么办?

zblogphp后台密码忘记了怎么办?

由于种种原因某些站长将zblog的后台密码忘记了,导致后台登录不上去。张春锁自媒体博客在这里向大家列举下二种处理方法:第一种方法(推荐):下载zblog官方工具“nologin”,下载地址:点击下载;或者去zblog官方论坛下载:点击进入。这个工具使用起来也非常简单,下载后解压,得到一个nologi...

如何选择虚拟主机、服务器?

如何选择虚拟主机、服务器?

在开始这篇文章前,张春锁自媒体博客给大家先来解释一下何谓服务器和虚拟主机虚拟主机:虚拟主机是在网络服务器上划分出一定的磁盘空间供用户放置站点、应用组件等,提供必要的站点功能、数据存放和传输功能。所谓虚拟主机,也叫“网站空间”,就是把一台运行在互联网上的服务器划分成多个“虚拟”的服务器,每一个虚拟主机...

ZBlogPHP禁止选中/复制网页上的文字

ZBlogPHP禁止选中/复制网页上的文字

博客内容被恶意不署名转载,原创文章被转载并比自己网站提前收录,这些问题都很让博主们烦恼,那么怎么让别人不能复制网站的文章呢,今天给大家介绍一个ZBlogPHP禁止右键选中复制网站文章的方法。主要功能:禁止选中或者复制网页上的文字,从而实现简单的防盗功能。实现方法很简单,几句CSS语句即可!body{...

网站备案被注销后的应对办法

网站备案被注销后的应对办法

”【工信部备案系统】工业和信息化部网站备案系统-短信通知:尊敬的用户XXX,您的备案XXX已被注销。特此通知!“很多网站管理员可能都遇到过这样的状况,网站运行的好好的,突然毫无预知地收到一条短信通知,说网站的备案被注销了,第二天再次访问网站,就会发现网站被机房自动屏蔽无法打开了,遇到这种情况,网站管...

中国8位域名大玩家

中国8位域名大玩家

4月22日小米公司启用新域名mi.com,原有域名xiaomi.com已跳转至mi.com。小米科技CEO雷军在微博表示更改域名是为适应小米国际化战略,“估计算得上中国互联网史上最贵域名”。有消息称小米为购买此域名支付了360万美元,约2000万元。2013年,有4家电商更换了域名:京东将原有的 3...

易企CMS - URL重写(伪静态)指南

易企CMS - URL重写(伪静态)指南

在开启URL重写之前请先确认您的主机所使用的服务器软件(如果不知道使用的是什么软件,请咨询主机提供商).下面按照服务器软件,进行介绍.1.apache如果服务器软件为apache,直接进入后台,点击导航里面的,网站设置,然后点击URL重写,再选择开启URL重写,提交以后,就可以了.如果不能正常生成....

发表评论

访客

◎欢迎参与讨论,请在这里发表您的看法和观点。