全方位站长技能、SEO优化学习平台
当前位置:网站首页 > 织梦笔记 > 正文

从入门到精通,织梦CMS伪静态教程全解析

作者:admin发布时间:2023-05-31分类:织梦笔记浏览:302评论:0


温馨提示:手机扫码可阅读当前文章!
文章简介:织梦CMS是一种基于PHP技术的网站建站系统,它可以用来快速构建一个高效的网站。为了提高网站的SEO优化效果,我们通常都会使用伪静态技术来进行网站的改进。伪静态技术可以使得网站的链接更加友好,同时也可以增加网站在搜索引擎中的收录率和排名。本...

织梦CMS是一种基于PHP技术的网站建站系统,它可以用来快速构建一个高效的网站。为了提高网站的SEO优化效果,我们通常都会使用伪静态技术来进行网站的改进。伪静态技术可以使得网站的链接更加友好,同时也可以增加网站在搜索引擎中的收录率和排名。本篇文章将为您详细介绍如何在织梦CMS中进行伪静态的配置。


973b1a1c562f80828b14f90084ac5dab.jpeg


一、什么是伪静态技术


伪静态技术(也称伪静态URL)是指通过改变动态网站的URL地址的形式来使得动态网页的URL变得更像静态网页的URL。而静态网页的URL更加清晰、简单且容易被搜索引擎爬虫收录,因此采用伪静态技术也能够提高网站的SEO优化效果。


在伪静态URL中,通常会将动态页面的URL形式转换为类似静态网页的URL形式。例如:http://example.com/index.php?id=101 转换为 http://example.com/index-101.html,这样的URL更加明确、精简,并且更加有利于搜索引擎收录。


二、织梦CMS伪静态配置


伪静态技术的实现需要在网站服务器中使用htaccess文件进行配置,而织梦CMS伪静态也是基于此原理进行实现。因此,我们需要创建一个.htaccess文件,并将以下内容复制到文件中:


rewriteengine on
 RewriteCond %{REQUEST_FILENAME} !-f
 RewriteCond %{REQUEST_FILENAME} !-d
 RewriteRule ^(.*)$ index.php/$1 [L]


接下来,我们将该文件放置在织梦的根目录下。当然,由于.htaccess是一个隐藏的系统配置文件,某些系统会默认不显示该文件,此时我们需要把该文件放在本地,然后通过FTP上传到织梦CMS的根目录下。


完成以上操作后,我们还需要进行一些参数的设置,以确保伪静态功能能够正常发挥作用。首先,在系统设置中选择“自定义URL地址”,然后将“使用伪静态”设置为“是”。这样,我们就启用了织梦CMS的伪静态功能。


接着,我们需要为每个文档、分类等页面设置自定义链接。例如:对于某个分类页面,我们可以将链接设置为“catalogue/123.html”,其中123指的是分类的编号。而对于文档页面,我们也可以将其链接设置为“article/123.html”,其中123指的是文章的编号。


最后,我们还需要将定义好的自定义链接保存,这样在后期的使用中,织梦CMS就可以自动将动态的链接转化成静态的链接,从而改善网站的SEO优化效果。


1、织梦CMS程序Nginx下通用规则


1.1 伪静态规则1


rewrite "^/list-([0-9]+)\.html$" /plus/list.php?tid=$1 last;
rewrite "^/list-([0-9]+)-([0-9]+)-([0-9]+)\.html$" /plus/list.php?tid=$1&totalresult=$2&PageNo=$3 last;
rewrite "^/view-([0-9]+)-1\.html$" /plus/view.php?arcID=$1 last;
rewrite "^/view-([0-9]+)-([0-9]+)\.html$" /plus/view.php?aid=$1&pageno=$2 last;
rewrite "^/plus/list-([0-9]+)\.html$" /plus/list.php?tid=$1 last;
rewrite "^/plus/list-([0-9]+)-([0-9]+)-([0-9]+)\.html$" /plus/list.php?tid=$1&totalresult=$2&PageNo=$3 last;
rewrite "^/plus/view-([0-9]+)-1\.html$" /plus/view.php?arcID=$1 last;
rewrite "^/plus/view-([0-9]+)-([0-9]+)\.html$" /plus/view.php?aid=$1&pageno=$2 last;
rewrite "^/tags.html$" /tags.php last;
rewrite "^/tag-([0-9]+)-([0-9]+)\.html$" /tags.php?/$1/$2/ last;


1.2  伪静态规则2


location / {
rewrite "^/index.html$" /index.php last;
rewrite "^/list-([0-9]+)\.html$" /plus/list.php?tid=$1 last;
rewrite "^/list-([0-9]+)-([0-9]+)-([0-9]+)\.html$" /plus/list.php?tid=$1&totalresult=$2&PageNo=$3 last;
rewrite "^/view-([0-9]+)-1\.html$" /plus/view.php?arcID=$1 last;
rewrite "^/view-([0-9]+)-([0-9]+)\.html$" /plus/view.php?aid=$1&pageno=$2 last;
rewrite "^/tags/$" /tags.php last;
rewrite "^/tags/(.*)/$" /tags.php?/$1/ last;
break;
}

1.3 伪静态规则3

location / {
#dedecms电脑端目录结构nginx伪静态
#首页
rewrite ^/index\.html$ /index.php;
#TAG标签
rewrite ^/tags\.html$/tags.php;
rewrite ^/tags/([0-9]+)\.html$/tags.php?\/$1;
rewrite ^/tags/([0-9]+)\.html$/tags.php?\/$1\/;
rewrite ^/tags/([0-9]+)_([0-9]+)\.html$ /tags.php?\/$1\/$2;
rewrite ^/tags/([0-9]+)_([0-9]+)\.html$  /tags.php?\/$1\/$2\/;
#列表栏目
rewrite ^/(.*)/$ /plus/list.php?tid=$1;
#列表栏目分页
rewrite ^/(.*)/list_([0-9]+)_([0-9]+)\.html$ /plus/list.php?tid=$1&PageNo=$2;
#文章页
rewrite ^/(.*)/([0-9]+)\.html$ /plus/view.php?aid=$1;
#文章页分页
rewrite ^/(.*)/([0-9]+)_([0-9]+)\.html$ /plus/view.php?aid=$1&pageno=$2;
#搜索页
rewrite ^/search/(.*)-([0-9]+)\.html$  /plus/search.php?q=$1&PageNo=$2&pagesize=10&searchtype=title;
rewrite ^/search/(.*)\.html$  /plus/search.php?q=$1&pagesize=10&searchtype=title;
}


2. 织梦程序Apache伪静态规则


2.1 伪静态规则1


RewriteRule ^"^/list-([0-9]+)\.html$" plus/list.php?tid=$1
RewriteRule ^"^/list-([0-9]+)-([0-9]+)-([0-9]+)\.html$" plus/list.php?tid=$1&totalresult=$2&PageNo=$3
RewriteRule ^"^/view-([0-9]+)-1\.html$" plus/view.php?arcID=$1
RewriteRule ^"^/view-([0-9]+)-([0-9]+)\.html$" plus/view.php?aid=$1&pageno=$2
RewriteRule ^"^/tags.html$" tags.php
RewriteRule ^"^/tag-([0-9]+)-([0-9]+)\.html$" tags.php?/$1/$2


2.2 伪静态规则2


 #Apache伪静态
RewriteEngine On
#RewriteRule ^index.html /index.php
#dede5.7列表页伪静态规则
#RewriteRule ^plus/list-([0-9]+)\.html$ /plus/list.php?tid=$1
#RewriteRule ^plus/list-([0-9]+)-([0-9]+)-([0-9]+)\.html$ /plus/list.php?tid=$1&TotalResult=$2&PageNo=$3
#RewriteRule ^plus/view-([0-9]+)-1.html$ /plus/view.php?arcID=$1
#文章页伪静态规则
#RewriteRule ^plus/view-([0-9]+)-([0-9]+)\.html$ /plus/view.php?aid=$1&pageno=$2


2.3 伪静态规则3


#dedecms电脑端目录结构apache伪静态
RewriteEngine On
RewriteBase /
#首页
RewriteRule ^index\.html$ index\.php
#TAG标签
RewriteRule ^tags\.html$    tags\.php
RewriteRule ^tags/([0-9]+)\.html$    tags\.php\?\/$1 [L]
RewriteRule ^tags/([0-9]+)\.html$    tags\.php\?\/$1\/
RewriteRule ^tags/([0-9]+)_([0-9]+)\.html$    tags\.php\?\/$1\/$2
RewriteRule ^tags/([0-9]+)_([0-9]+)\.html$    tags\.php\?\/$1\/$2\/
#列表栏目
RewriteRule ^(.*)/$ /plus/list.php?tid=$1
#列表栏目分页
RewriteRule ^(.*)/list_([0-9]+)_([0-9]+)\.html$ /plus/list.php?tid=$2&PageNo=$3
#文章页
RewriteRule ^(.*)/([0-9]+)\.html$ /plus/view.php?aid=$2
#文章页分页
RewriteRule ^(.*)/([0-9]+)_([0-9]+)\.html$ /plus/view.php?aid=$2&pageno=$3
#搜索页
RewriteRule ^search/(.*)-([0-9]+)\.html$  /plus/search.php?q=$1&PageNo=$2&pagesize=10&searchtype=title
RewriteRule ^search/(.*)\.html$  /plus/search.php?q=$1&pagesize=10&searchtype=title


3. 织梦cms程序IIS7/IIS8/IIS10web.config伪静态规则


3.1 IIS伪静态规则1


 
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
    <system.webServer>
        <rewrite>
            <rules>
                <rule name="首页">
                    <match url="^index.html$" ignoreCase="false" />
                    <action type="Rewrite" url="index.php" appendQueryString="false" />
                </rule>
                <rule name="tag首页">
                    <match url="^tags.html$" ignoreCase="false" />
                    <action type="Rewrite" url="tags.php" appendQueryString="false" />
                </rule>
                <rule name="tag列表">
                    <match url="^tags/([0-9]+).html$" ignoreCase="false" />
                    <action type="Rewrite" url="/tags.php?/{R:1}" appendQueryString="false" />
                </rule>
                <rule name="tag列表最后有左斜杠">
                    <match url="^tags/([0-9]+).html$" ignoreCase="false" />
                    <action type="Rewrite" url="/tags.php?/{R:1}/" appendQueryString="false" />
                </rule>
                <rule name="tag列表分页">
                    <match url="^tags/([0-9]+)_([0-9]+).html$" ignoreCase="false" />
                    <action type="Rewrite" url="/tags.php?/{R:1}/{R:2}" appendQueryString="false" />
                </rule>
                <rule name="tag列表分页最后有左斜杠">
                    <match url="^tags/([0-9]+)_([0-9]+).html$" ignoreCase="false" />
                    <action type="Rewrite" url="/tags.php?/{R:1}/{R:2}/" appendQueryString="false" />
                </rule>
                <rule name="列表">
                    <match url="^(.*)/$" ignoreCase="false" />
                    <action type="Rewrite" url="/plus/list.php?tid={R:1}" appendQueryString="false" />
                </rule>
                <rule name="列表分页">
                    <match url="^(.*)/list_([0-9]+)_([0-9]+).html$" ignoreCase="false" />
                    <action type="Rewrite" url="/plus/list.php?tid={R:2}&amp;PageNo={R:3}" appendQueryString="false" />
                </rule>
                <rule name="文章页">
                    <match url="^(.*)/([0-9]+).html$" ignoreCase="false" />
                    <action type="Rewrite" url="/plus/view.php?aid={R:2}" appendQueryString="false" />
                </rule>
                <rule name="文章分页">
                    <match url="^(.*)/([0-9]+)_([0-9]+).html$" ignoreCase="false" />
                    <action type="Rewrite" url="/plus/view.php?aid={R:2}&amp;pageno={R:3}" appendQueryString="false" />
                </rule>
                <rule name="搜索页分页">
                    <match url="^search/(.*)-([0-9]+).html$" ignoreCase="false" />
                    <action type="Rewrite"
                        url="/plus/search.php?q={R:1}&amp;PageNo={R:2}&amp;pagesize=10&amp;searchtype=title"
                        appendQueryString="false" />
                </rule>
                <rule name="搜索页">
                    <match url="^search/(.*).html$" ignoreCase="false" />
                    <action type="Rewrite" url="/plus/search.php?q={R:1}&amp;pagesize=10&amp;searchtype=title"
                        appendQueryString="false" />
                </rule>
            </rules>
        </rewrite>
    </system.webServer>
</configuration>


3.2 IIS伪静态规则2


<?xml version="1.0" encoding="UTF-8"?>
<configuration>
    <system.webServer>
        <rewrite>
            <rules>
                <rule name="已导入的规则 1">
                    <match url="^list-([0-9]+).html$" ignoreCase="false" />
                    <action type="Rewrite" url="/plus/list.php?tid={R:1}" appendQueryString="false" />
                </rule>
                <rule name="已导入的规则 2">
                    <match url="^list-([0-9]+)-([0-9]+)-([0-9]+).html$" ignoreCase="false" />
                    <action type="Rewrite" url="/plus/list.php?tid={R:1}&amp;totalresult={R:2}&amp;PageNo={R:3}"
                        appendQueryString="false" />
                </rule>
                <rule name="已导入的规则 3">
                    <match url="^view-([0-9]+)-1.html$" ignoreCase="false" />
                    <action type="Rewrite" url="/plus/view.php?arcID={R:1}" appendQueryString="false" />
                </rule>
                <rule name="已导入的规则 4">
                    <match url="^view-([0-9]+)-([0-9]+).html$" ignoreCase="false" />
                    <action type="Rewrite" url="/plus/view.php?aid={R:1}&amp;pageno={R:2}" appendQueryString="false" />
                </rule>
            </rules>
        </rewrite>
    </system.webServer>
</configuration>


4. 织梦CMS程序httpd.ini伪静态规则


#首页伪静态规则,如果不使用动态首页,请勿必删除这一行,否则打开首页会出现死循环
RewriteRule ^(.*)/index\.html $1/index\.php [I]
#列表页伪静态规则
RewriteRule ^(.*)/list-([0-9]+)\.html $1/plus/list\.php\?tid=$2 [I]
RewriteRule ^(.*)/list-([0-9]+)-([0-9]+)-([0-9]+)\.html $1/plus/list\.php\?tid=$2&TotalResult=$3&PageNo=$4 [I]
#文章页伪静态规则
RewriteRule ^(.*)/view-([0-9]+)-([0-9]+)\.html $1/plus/view\.php\?arcID=$2&pageno=$3 [I]
#搜索伪静态规则
RewriteRule ^(.*)/search\.html(?:(\?.*))* $1/search\.php?$2 [I]
#TAG标签伪静态规则
RewriteRule ^(.*)/tags\.html $1/tags\.php [I] RewriteRule ^(.*)/tags/(.*)(?:(\?.*))* $1/tags\.php\?\/$2 [I]
RewriteRule ^(.*)/tags/(.*)\/(?:(\?.*))* $1/tags\.php\?\/$2\/ [I]
RewriteRule ^(.*)/tags/(.*)\/([0-9])(?:(\?.*))* $1/tags\.php\?\/$2\/$3 [I]
RewriteRule ^(.*)/tags/(.*)\/([0-9])\/(?:(\?.*))* $1/tags\.php\?\/$2\/$3\/ [I]
#问答伪静态规则,适用于DedeCmsV5.3-5.6版本,需要修改几处程序
RewriteRule ^(.*)/post\.html $1/post\.php [I]
RewriteRule ^(.*)/type\.html $1/type\.php [I]
RewriteRule ^(.*)/question-([0-9]+)\.html $1/question\.php\?id=$2 [I]
RewriteRule ^(.*)/browser-1-([0-9]+)\.html $1/browser\.php\?tid=$2 [I]
RewriteRule ^(.*)/browser-2-([0-9]+)\.html $1/browser\.php\?tid2=$2 [I]
RewriteRule ^(.*)/browser-1-([0-9]+)-([0-9]+)\.html $1/browser\.php\?tid=$2&page=$3 [I]
RewriteRule ^(.*)/browser-2-([0-9]+)-([0-9]+)\.html $1/browser\.php\?tid2=$2&page=$3 [I]
RewriteRule ^(.*)/browser-([0-9]+)\.html $1/browser\.php\?lm=$2 [I]
RewriteRule ^(.*)/browser-1-([0-9]+)-([0-9]+)\.html $1/browser\.php\?tid=$2&lm=$3 [I]
RewriteRule ^(.*)/browser-2-([0-9]+)-([0-9]+)\.html $1/browser\.php\?tid2=$2&lm=$3 [I]



三、织梦CMS伪静态技术的优势和注意事项


1. 伪静态优势:


1.伪静态技术可以提高网站的SEO排名。由于搜索引擎更喜欢使用静态的URL,因此使用伪静态技术可以使得网站的链接更加友好,增加搜索引擎的收录率和排名。


2.伪静态技术可以改善用户的浏览体验。静态的URL更加明确,能够让用户更加轻松地了解到网页的内容。


2. 设置伪静态的注意事项:


1.使用伪静态技术需要注意文件的命名规则,避免出现重复、不规范的文件命名造成URL冲突。


2.使用伪静态技术需要小心谨慎,特别是在没有经验的情况下。配置不当可能会导致系统崩溃、链接不敏感等问题。因此,在设置之前一定要备份好相关的文件和数据,以防万一。


3.有些虚拟主机的服务器开启了Safe_Mode,可能会导致伪静态无法正常使用,此时建议使用静态页面或者试图与主机提供商联系以获得技术支持。

欢迎您,来自美国–俄亥俄州–特拉华县–都柏林的朋友,您的IP:18.216.6.100,您的网络:Amazon数据中心

标签:织梦cms伪静态


欢迎 发表评论:

  • 请填写验证码
织梦笔记排行
随机推荐
猜你喜欢

服务热线

1888888888

要发发发发发发

站长微信公众号

站长微信公众号

分享:

支付宝

微信