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

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

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

非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给目录添加反斜杠的伪静态规则方法” 的相关文章

九月简单博客主题问题反馈

九月简单博客主题问题反馈

问题反馈,望得到帮助:1、首页上面的推荐阅读如何呈现文章。2、文章列表页如何实现缩略图,安装的缩略图插件开启后未能实现目的,随机图片可以显示。插件本身也删除不了。3、如果使用多说插件,文章内容页的评论重叠,不能展开显示,关闭插件就可以实现评论层叠样式。4、主导航如何实现二级导航下拉菜单。5、主题配置...

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

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

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

Zblog程序如何添加单页面

Zblog程序如何添加单页面

第一步,我们要对zblog的模板修改有一定的基础,懂得一些基本的知识才行 第二步,找到我们要修改的模板文件,路径如下:THEMES/你的模板文件夹/TEMPLATE/default.html,default.html是模板的首页,我们在这里建议用DW来编辑,通过ftp把这个文件下载到本地。...

zblog博客程序忘记后台登陆密码的解决方法

zblog博客程序忘记后台登陆密码的解决方法

FTP软件下载你的DATA目录下的数据库文件,保存到本地后,用数据库编辑软件打开数据库。打开你存放用户名和密码的表(默认是blog_Member)我们会看到你的默认用户是ADMIN后边一列mem_password下面就是用32位加密过的对应密码,我们把这一格里面的内容全部删除。替换成下面其中一个。a...

WP如何防止图片浪费空间流量及图片盗链

WP如何防止图片浪费空间流量及图片盗链

无意中看到破折君的博客,他让我们这些使用WORDPRESS博客的博友防止图片盗链,也减轻主机的流量问题,我觉得这篇文章相当不错,特意转载过来自己收藏,也分享给朋友们。事实上对于wordpress而言,因为我们一般都是用linux主机,那么我们只要修改根目录下的htaccess文件就行,但是有的时候修...

Discuz论坛忘记了管理员密码怎么办?

Discuz论坛忘记了管理员密码怎么办?

在网站根目录下的子目录uc_server/data中打开找到文件config.inc.php以及 config/config_global.php、config/config_ucenter.php (这两个如果没有下面代码可以不用修改)找到类似以下代码:define('UC_FOUNDER...

发表评论

访客

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