Home CMS Tutorial DEDECMS How dedecms implements pseudo-static throughout the site

How dedecms implements pseudo-static throughout the site

Jul 20, 2019 pm 01:54 PM

How dedecms implements pseudo-static throughout the site

The whole site of DedeCms is pseudo-static, which is to facilitate management and SEO. DedeCms generates static html files by default, which is very friendly to optimization, but there are still some pages. It is in a dynamic form (such as Tag page, website content search page, DedeCms Q&A page, etc.). In order to make these pages better included by search engines, pseudo-static needs to be made. Although the DedeCms system can generate static HTML file, but if the amount of content updated every day is particularly large, generating html files will also become a burden on the system and manpower, so it can also be made into a pseudo-static form, thus eliminating the need for tedious generation of html files.

Make the entire DedeCms site static, which requires the support of the mod_rewrite pseudo-static module. As long as the webmaster is proficient in .htaccess regular expressions, he can make the entire dede website static, which is more in line with search engines and can also avoid repeated URLs. DedeCms full-site pseudo-static configuration is a bit troublesome, mainly because we need to manually modify the source code. The organizing steps are as follows:

1. First, enable the pseudo-static function of the site. Log in to the dede administrator backend->System->System Basic Parameters->Core Settings->Select "Yes" whether to use pseudo-static.

2. Modify the source program to achieve pseudo-static homepage, pseudo-static channel page, pseudo-static list page, and pseudo-static article page. This process is more complicated and is not as good as other PHP open source programs. Simple.

3. Create and write .htaccess and .htaccess file rules and upload them to the installation directory of DedeCms.

DedeCms full-site pseudo-static tutorial: including list|article|Q&A|search|TAG pseudo-static rules:

1. Whether the website server and website space support it Pseudo-static:

This is particularly important, or all settings will not work. If your website uses a server, you can set it up yourself. If it is a space, you can ask the IDC service provider customer service to see if it supports pseudo-static (general spaces support pseudo-static). Apache server pseudo-static is relatively simple, just add the corresponding pseudo-static rules directly to the .htaccess file; and to implement pseudo-static on IIS server, you need to load the Rewrite component and then configure the httpd.ini file.

2. Turn on DedeCMS pseudo-static:

1) DedeCms backend - system parameters - core settings - whether to use pseudo-static: select "Yes";

2) If you enable the DedeCms question and answer module, in the background - system parameters - module settings - whether to use Rewrite: select "Yes";

3) When creating a column or adding columns in batches , column list options: select "Use dynamic pages"; when adding a new article, publishing options: select "dynamic browsing only". Similarly, you can also change their templates so that they default to these two values, once and for all. The modification method is very simple, the method is as follows:

Find the background file: /dede/templets/catalog_add.htm Modify the default "Use dynamic page" when adding columns

<td height="26" style="padding-left:10px;">栏目列表选项:</td>
            <td><input type=&#39;radio&#39; name=&#39;isdefault&#39; value=&#39;1&#39; class=&#39;np&#39; checked="checked" />链接到默认页
              <input type=&#39;radio&#39; name=&#39;isdefault&#39; value=&#39;0&#39; class=&#39;np&#39; />链接到列表第一页
              <input type=&#39;radio&#39; name=&#39;isdefault&#39; value=&#39;-1&#39; class=&#39;np&#39; />使用动态页</td>
Copy after login

Change to:

<td height="26" style="padding-left:10px;">栏目列表选项:</td>
            <td><input type=&#39;radio&#39; name=&#39;isdefault&#39; value=&#39;1&#39; class=&#39;np&#39; />链接到默认页
              <input type=&#39;radio&#39; name=&#39;isdefault&#39; value=&#39;0&#39; class=&#39;np&#39; />链接到列表第一页
              <input type=&#39;radio&#39; name=&#39;isdefault&#39; value=&#39;-1&#39; checked="checked" class=&#39;np&#39; />使用动态页</td>
Copy after login

Found the background file: /dede/templets/article_add.htm Modify the default "dynamic browsing only" when adding articles

<td width="90">发布选项:</td>
          <td width="379"><input name="ishtml" type="radio" class="np" value="1" checked="1" />生成HTML
  <input type="radio" name="ishtml" class="np" value="0"/>仅动态浏览 </td>
Copy after login

Changed to:

<td width="90">发布选项:</td>
          <td width="379"><input name="ishtml" type="radio" class="np" value="1" />生成HTML
  <input type="radio" name="ishtml" class="np" value="0" checked="1"/>仅动态浏览 </td>
Copy after login

4) If the website already has generated static columns or article HTML, you only need to execute the following statement in the background-system-SQL command line tool:

update dede_arctype set isdefault=-1;
update dede_archives set ismake=-1;
Copy after login

Note: dede in the command is the data table prefix when the website is installed. Replace according to actual situation.

3. Turning on DedeCms pseudo-static support cannot be completely configured in the background. There are many places that still need to be modified manually. The following explains the implementation method of DedeCms full-site pseudo-static, which is applicable to V5.3 and above. This time the DedeCms pseudo-static test environment is Windows IIS6. The principle of pseudo-static implementation for Linux or other servers is the same, as long as the idea is clear.

1) Pseudo-static home page of DedeCms:

Delete index.html in the root directory of the site and do not update the home page HTML in the future. Of course, you can also choose not to use a dynamic home page.

2) DedeCms channel | list page | article page pseudo-static:

Mainly achieved by modifying the two functions GetFileName() and GetTypeUrl(). For DedeCms V5.3, DedeCms V5.5 and DedeCms V5.6 versions, open /include/channelunit.func.php for modification. Note: DedeCms V5.7, the path of this file has changed, you can open /include/helpers/channelunit.helper.php.

A. Change the following code in GetTypeUrl():

//动态
  $reurl = $GLOBALS[&#39;cfg_phpurl&#39;]."/list.php?tid=".$typeid;
  替换为
  //动态
  $reurl = "/category/list-".$typeid.".html";
Copy after login

B. Change the following code in GetFileName():

 //动态文章
  if($cfg_rewrite == &#39;Y&#39;)
  {
  return $GLOBALS["cfg_plus_dir"]."/view-".$aid.&#39;-1.html&#39;;
  }
  替换为
  //动态文章
  if($cfg_rewrite == &#39;Y&#39;)
  {
  return "/archives/view-".$aid.&#39;-1.html&#39;;
  }
Copy after login

3) DedeCms list paging pseudo-static:

Open /include/arc.listview.class.php and find the end of the GetPageListDM() function to get the dynamic paging list:
Replace

$plist = str_replace(&#39;.php?tid=&#39;, &#39;-&#39;, $plist);
Copy after login

with

 $plist = str_replace('plus', 'category', $plist);//将默认的plus替换成category
  $plist = str_replace(&#39;.php?tid=&#39;, &#39;-&#39;, $plist);
Copy after login

Change the default link format of list paging /plus/list-1-2-1.html to /category/list-1-2-1.html. This step does not need to be changed.

4) DedeCms article paging pseudo-static:

Open /include/arc.archives.class.php and find the end piece of the GetPagebreakDM() function to get the dynamic paging list:

  $PageList = str_replace(".php?aid=","-",$PageList);
Copy after login

is replaced with

 $plist = str_replace(&#39;plus&#39;, &#39;archives&#39;, $plist);//将默认的plus替换成archives
 $PageList = str_replace(".php?aid=","-",$PageList);
Copy after login

5) DedeCmsTAG tag pseudo-static:

DedeCms默认的TAG标签URL,形如/tags.php?/dedecms5.7/,特别的难看。打开/include/taglib/tag.lib.php,找到lib_tag()函数下的: 

$row[&#39;link&#39;] = $cfg_cmsurl."/tags.php?/".urlencode($row[&#39;keyword&#39;])."/";
Copy after login

替换为

$row[&#39;link&#39;] = $cfg_cmsurl."/tags/".urlencode($row[&#39;keyword&#39;])."/";
Copy after login

到这里,TAG标签URL中的“.php?”号就去掉了。

6)DedeCms搜索伪静态:

DedeCms搜索URL静态化比较麻烦,附带参数多不说,参数也可能变化,像搜索结果分页的URL就特麻烦,伪静态规则匹配复杂。将搜索URL中“search.php?…”直接替换为“search.html?…”,至于“?”号之后的参数以任意字符进行匹配。
依次打开include文件夹下的channelunit.func.php、arc.searchview.class.php、arc.taglist.class.php以及/include/taglib/hotwords.lib.php,查找“search.php?”替换为“search.html?”即可。

7)DedeCms问答伪静态:

问答模块的伪静态实现比较简单,只要后台开启伪静态支持即可,至于个别页面,如ask目录下的browser.php、question.php以及include目录下的common.inc.php、functions.inc.php都需要简单修改才可以匹配伪静态规则。注意一点,DedeCms V5.7问答模块整体升级了,之前的规则已经不适用了。

4、DedeCms伪静态规则:

依照上面的步骤修改完毕,接下来配置好httpd.ini文件和.htaccess文件伪静态规则,则DedeCms全站伪静态就完美实现。

1)IIS伪静态

打开httpd.ini文件,加入如下规则:

#首页伪静态规则,如果不使用动态首页,请勿必删除这一行,否则打开首页会出现死循环
  RewriteRule ^(.*)/index\.html $1/index\.php [I]
  #列表页伪静态规则
  RewriteRule ^(.*)/category/list-([0-9]+)\.html $1/plus/list\.php\?tid=$2 [I]
  RewriteRule ^(.*)/category/list-([0-9]+)-([0-9]+)-([0-9]+)\.html $1/plus/list\.php\?tid=$2&TotalResult=$3&PageNo=$4 [I]
  #文章页伪静态规则
  RewriteRule ^(.*)/archives/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]
Copy after login

2)Apache伪静态:

打开.htaccess文件,加入如下规则:

  #提供部分规则作参考
  RewriteRule ^category/list-([0-9]+)\.html$ /plus/list.php?tid=$1
  RewriteRule ^category/list-([0-9]+)-([0-9]+)-([0-9]+)\.html$ /plus/list.php?tid=$1&totalresult=$2&PageNo=$3
  RewriteRule ^archives/view-([0-9]+)-([0-9]+)\.html$ /plus/view.php?aid=$1&pageno=$2
        RewriteRule ^index.html$ index.php
Copy after login

更多DedeCMS相关技术文章,请访问DedeCMS教程栏目进行学习!

The above is the detailed content of How dedecms implements pseudo-static throughout the site. For more information, please follow other related articles on the PHP Chinese website!

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Optimizing website SEO: practice of pseudo-static hiding php suffix Optimizing website SEO: practice of pseudo-static hiding php suffix Mar 07, 2024 pm 12:27 PM

As we all know, optimizing the SEO of a website is a very important part of website operation. The default URLs of dynamic web systems (such as PHP) used by many websites have extensions (.php, .html, etc.), which will affect the SEO effect of the website. In order to improve the optimization effect of the website, a common practice is to change the dynamic URL to a pseudo-static URL to hide the extension name and improve the user experience and search engine ranking of the website. This article will take "pseudo-static hidden php suffix" as the theme, introduce how to achieve this optimization in PHP websites, and

Where is the imperial cms resource network template? Where is the imperial cms resource network template? Apr 17, 2024 am 10:00 AM

Empire CMS template download location: Official template download: https://www.phome.net/template/ Third-party template website: https://www.dedecms.com/diy/https://www.0978.com.cn /https://www.jiaocheng.com/Installation method: Download template Unzip template Upload template Select template

How dedecms implements template replacement How dedecms implements template replacement Apr 16, 2024 pm 12:12 PM

Template replacement can be implemented in Dedecms through the following steps: modify the global.cfg file and set the required language pack. Modify the taglib.inc.php hook file and add support for language suffix template files. Create a new template file with a language suffix and modify the required content. Clear Dedecms cache.

What website can dedecms do? What website can dedecms do? Apr 16, 2024 pm 12:24 PM

Dedecms is an open source CMS that can be used to create various types of websites, including: news websites, blogs, e-commerce websites, forums and community websites, educational websites, portals, other types of websites (such as corporate websites, personal websites, photo album websites, video sharing website)

How to upload local videos to dedecms How to upload local videos to dedecms Apr 16, 2024 pm 12:39 PM

How to upload local videos using Dedecms? Prepare the video file in a format that is supported by Dedecms. Log in to the Dedecms management backend and create a new video category. Upload video files on the video management page, fill in the relevant information and select the video category. To embed a video while editing an article, enter the file name of the uploaded video and adjust its dimensions.

What loopholes does dedecms have? What loopholes does dedecms have? Aug 03, 2023 pm 03:56 PM

DedeCMS is an open source content management system that has some potential vulnerabilities and security risks: 1. SQL injection vulnerability. Attackers can perform unauthorized operations or obtain sensitive data by constructing malicious SQL query statements; 2. File Upload vulnerability, attackers can upload files containing malicious code to the server to execute arbitrary code or obtain server permissions; 3. Sensitive information leakage; 4. Unauthenticated vulnerability exploitation.

How to use dedecms How to use dedecms Apr 16, 2024 pm 12:15 PM

Dedecms is an open source Chinese CMS system that provides content management, template system and security protection. The specific usage includes the following steps: 1. Install Dedecms. 2. Configure the database. 3. Log in to the management interface. 4. Create content. 5. Set up the template. 6. Manage users. 7. Maintain the system.

Improve website security: Pseudo-static rules implement PHP suffix hiding Improve website security: Pseudo-static rules implement PHP suffix hiding Mar 07, 2024 am 11:33 AM

Improve website security: Pseudo-static rules implement PHP suffix hiding. With the development of the Internet, website security issues have become increasingly prominent, including the prevention of malicious attacks and the protection of user data. An effective measure is to hide the PHP suffix through pseudo-static rules, which helps improve the security of the website and protect user privacy. In achieving this goal, we need to use some specific code examples to demonstrate how to achieve PHP suffix hiding. First, we need to understand what pseudo-static rules are. Pseudo-static is a method of converting dynamic web page links into

See all articles