Home  >  Article  >  CMS Tutorial  >  How to modify the template path of Dede website

How to modify the template path of Dede website

藏色散人
藏色散人Original
2019-12-12 11:02:232866browse

How to modify the template path of Dede website

Dede网站怎么修改模板路径?

相信大家用Dede架构网站的有很多吧,很多时候我们是直接复制一个templets\default文件夹修改掉名字来达到修改模版路径的目的,但是如果自己做的模板,往往很多地方考虑的不周到,因为不是所有功能都用得到。访问一些不存在模板的功能,有时候会暴露模板的真实路径

推荐学习:织梦cms

1,批量修改模版文件

方法,使用批量修改工具。比如你模版目录是templets\xahot.net,那么你需要批量替换{dede:global.cfg_templets_skin/}和$cfg_templets_skin; ?>为/templets/default或者其他安全路径。PS,批量修改工具网上有很多,我用的服务器那个很好用(绝非AD)。

2,模板放进数据库

用dede程序自带的自定义标记功能来防止模板被下载也不错。简单来说就是把真正的模板放到数据库里面,html模板只是一个壳子没有内容。

具体操作步骤:进dede后台,新建一个自定义标记,标记名称为xahot。至于内容你可以把模板文件的内容全复制进去。然后把模板里的内容清空,写上自定义标记代码{dede:mytag ismake='yes'/} 好了,现在即使模板被下载,泄漏的也只是这句自定义标记而已。

3,使用网站的伪静态(url重写)功能来重置链接

A,服务器支持.htaccess(linux)文件的在根目录建一个.htaccess,按以下方法修改,

比如我的模板文件放在/templest/xahot.net/这个目录

现在我要设置一个规则,只要访问模板目录下的任何文件,都显示主页内容。

改一下.htaccess文件:

RewriteEngine On
RewriteBase /
ErrorDocument 404 /
RewriteRule templest/xa /

注意最后那条规则,意思是只要访问的地址里面包含“templets/xa”,就会显示主页的内容。

可以看到我的模板目录名没写全,只要以xa开头就行了,这样既保护了模板,又不会暴露模板的路径。

B,IIS类网站方法httpd.ini写法(具体httpd.ini放置不多讲,可以自己搜索下)

[ISAPI_Rewrite]
#3600 = 1 hour
CacheClockRate 3600
RepeatLimit 32
RewriteRule ^(.*)/aa?(.+)$ $1/templest/xa$2.htm [L]

IIS的只能返回404错误页面,先设置一个404页面,让他随便返回吧(实际测试可用)

对于喜欢猜解路径的,不论怎样猜都返回一个错误页牛逼吧!

综述:第一种方法和最后一种方法结合起来比较好用也很有效,修改模版也方便。第二种修改起来比较麻烦,不推荐使用。

The above is the detailed content of How to modify the template path of Dede website. For more information, please follow other related articles on the PHP Chinese website!

Statement:
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