-
帝国CMS 7.2 默认伪静态规则配置
- 时间:2025-03-28 22:53:08 来源: 人气:2
为了优化网站的URL结构,提升搜索引擎排名和用户体验,伪静态规则的配置显得尤为重要。以下是针对APACHE、IIS6、IIS7以及Nginx服务器环境下的伪静态规则配置指南,供您参考。
对于APACHE服务器,可以通过.htaccess文件实现URL重写功能。以下是一个示例:
RewriteEngine On
ErrorDocument 404 /404.html
Rewritebase /
#信息列表
RewriteCond %{QUERY_STRING} ^(.*)$
RewriteRule ^listinfo-(.+?)-(.+?).html$ /e/action/ListInfo/index.php?classid=$1&page=$2
#信息内容页
RewriteCond %{QUERY_STRING} ^(.*)$
RewriteRule ^showinfo-(.+?)-(.+?)-(.+?).html$ /e/action/ShowInfo.php?classid=$1&id=$2&page=$3
#标题分类列表页
RewriteCond %{QUERY_STRING} ^(.*)$
RewriteRule ^infotype-(.+?)-(.+?).html$ /e/action/InfoType/index.php?ttid=$1&page=$2
#TAGS信息列表页
RewriteCond %{QUERY_STRING} ^(.*)$
RewriteRule ^tags-(.+?)-(.+?).html$ /e/tags/index.php?tagname=$1&page=$2
#评论列表页
RewriteCond %{QUERY_STRING} ^(.*)$
RewriteRule ^comment-(.+?)-(.+?)-(.+?)-(.+?)-(.+?)-(.+?).html$ /e/pl/index.php?doaction=$1&classid=$2&id=$3&page=$4&myorder=$5&tempid=$6
IIS6环境下,需要编辑httpd.ini文件来实现URL重写:
[ISAPI_Rewrite]
# 3600 = 1 hour
CacheClockRate 3600
RepeatLimit 32
#信息列表
RewriteRule ^(.*)listinfo-(.+?)-(.+?).html$ $1/e/action/ListInfo/index.php?classid=$2&page=$3
#信息内容页
RewriteRule ^(.*)showinfo-(.+?)-(.+?)-(.+?).html$ $1/e/action/ShowInfo.php?classid=$2&id=$3&page=$4
#标题分类列表页
RewriteRule ^(.*)infotype-(.+?)-(.+?).html$ $1/e/action/InfoType/index.php?ttid=$2&page=$3
#TAGS信息列表页
RewriteRule ^(.*)tags-(.+?)-(.+?).html$ $1/e/tags/index.php?tagname=$2&page=$3
#评论列表页
RewriteRule ^(.*)comment-(.+?)-(.+?)-(.+?)-(.+?)-(.+?)-(.+?).html$ $1/e/pl/index.php?doaction=$2&classid=$3&id=$4&page=$5&myorder=$6&tempid=$7
#搜索伪静态
IIS7则通过web.config文件进行配置:
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<!--帝国7.2默认规则 IIS7的rule name不能重复相同-->
<rewrite>
<rules>
<rule name="listinfo">
<match url="^(.*/)*listinfo-(.+?)-(.+?).html?*(.*)$" />
<action type="Rewrite" url="{R:1}/e/action/ListInfo/index.php?classid={R:2}&page={R:3}" />
</rule>
<rule name="showinfo">
<match url="^(.*/)*showinfo-(.+?)-(.+?)-(.+?).html?*(.*)$" />
<action type="Rewrite" url="{R:1}/e/action/ShowInfo.php?classid={R:2}&id={R:3}&page={R:4}" />
</rule>
<rule name="infotype">
<match url="^(.*/)*infotype-(.+?)-(.+?).html?*(.*)$" />
<action type="Rewrite" url="{R:1}/e/action/InfoType/index.php?ttid={R:2}&page={R:3}" />
</rule>
<rule name="tags">
<match url="^(.*/)*tags-(.+?)-(.+?).html?*(.*)$" />
<action type="Rewrite" url="{R:1}/e/tags/index.php?tagname={R:2}&page={R:3}" />
</rule>
<rule name="comment">
<match url="^(.*/)*comment-(.+?)-(.+?)-(.+?)-(.+?)-(.+?)-(.+?).html?*(.*)$"/>
<action type="Rewrite" url="{R:1}/e/pl/index.php?doaction={R:2}&={R:3}&={R:4}&page={R:5}&myorder={R:6}&tempid={R:7}" />
</rule>
</rules>
</rewrite>
</system.webServer>
</configuration>
Nginx服务器的伪静态规则如下所示:
rewrite ^([^.]*)/listinfo-(.+?)-(.+?).html$ $1/e/action/ListInfo/index.php?classid=$2&page=$3 last;
rewrite ^([^.]*)/showinfo-(.+?)-(.+?)-(.+?).html$ $1/e/action/ShowInfo.php?classid=$2&id=$3&page=$4 last;
rewrite ^([^.]*)/infotype-(.+?)-(.+?).html$ $1/e/action/InfoType/index.php?ttid=$2&page=$3 last;
rewrite ^([^.]*)/tags-(.+?)-(.+?).html$ $1/e/tags/index.php?tagname=$2&page=$3 last;
rewrite ^([^.]*)/comment-(.+?)-(.+?)-(.+?)-(.+?)-(.+?)-(.+?).html$ $1/e/pl/index.php?doaction=$2&classid=$3&id=$4&page=$5&myorder=$6&tempid=$7 last;
if (!-e $request_filename) {
return 404;
}
以上规则仅供参考,您可以根据实际需求进行调整,以确保其更加严谨和符合特定场景。请确保在修改前备份相关文件,以免影响网站正常运行。
相关文章
-
在留言板和后台留言审核面板中显示留言者的IP地址,是增强网站安全性和管理效率的重要功能。通过记录和展示IP地址,管理员可以更方便地追踪留言来源,确保内容的真实性和合法性。本文将详细介绍如何实现这一功能,并优化搜索引擎排名(SEO)。 首先,我们需要了解如何在代码中正确插入IP地址的显示逻辑。以下是...2025-03-29
-
在网站开发中,保护用户隐私是一个重要的考虑因素。当您在分类信息内容页添加了发布人的IP显示功能时,可能会面临如何隐藏IP地址的部分数字以保护用户隐私的问题。本文将介绍一种方法,让您能够像处理评论中的IP地址一样,将IP地址的最后一位数字替换为“*”。 为了实现这一功能,您可以使用PHP代码对IP地...2025-03-29
-
创建符合SEO标准的Google Sitemap对于提高网站在搜索引擎中的可见性至关重要。以下是一篇经过改写的文章,详细介绍了如何利用栏目分别创建不同的Sitemap,并确保其符合Google的要求。 技术整理:24mp3技术支持:wm_chief, hicode 制作Google Sitema...2025-03-29
-
在构建动态网站时,使用循环结构来展示数据是一种常见的做法。例如,在EmpireCMS中,我们可以利用[e:loop]标签来实现这一功能。下面是一篇关于如何使用[e:loop]标签生成友情链接列表的文章,旨在优化搜索引擎排名(SEO),同时确保代码的可读性和功能性。 在EmpireCMS中,[e:l...2025-03-29