杰奇通过伪静态防止模板被盗

2017-09-23T23:06:00

似乎很多网上的模板都已经自带了伪静态配置文件,也写了相关的规则,但是问题在于如果是自己开发模板,就显得比较烦了,访问者通过浏览就可以随意进入模板目录,然后将所有的代码都复制下来,这就比较尴尬了。所以可以通过简单的方法,让盗模板的人,转移到错误的页面。

如果是用于.htaccess文件
对于杰奇1.7版本,写法如下:

RewriteRule ^modules/article/templates/$ 404.html
RewriteRule ^templates/(.*).html$ 404.html
RewriteRule ^themes/自定义模板/(.*).html$ 404.html
RewriteRule ^自定义路径/(.*).html$ 404.html

对于1.8及2.2版本,写法如下:

RewriteRule ^modules/article/templates/$ 404.html
RewriteRule ^modules/article/templates/blocks/$ 404.html
RewriteRule ^templates/(.*).html$ 404.html
RewriteRule ^themes/自定义模板/(.*).html$ 404.html
RewriteRule ^自定义首页路径/(.*).html$ 404.html

如果是用于httpd.ini文件
对于杰奇1.7版本,写法如下:

RewriteRule ^(.*)/自定义首页路径/(.*)\.html$ $1/404\.html
RewriteRule ^(.*)/templates/(.*)\.html$ $1/404\.html
RewriteRule ^(.*)/themes/自定义模板路径/(.*)\.html$ $1/404\.html
RewriteRule ^(.*)/modules/article/templates/$ $1/404\.html
RewriteRule ^(.*)/modules/article/templates/(.*)\.html$ $1/404\.html

对于1.8及2.2版本,写法如下:

RewriteRule ^(.*)/自定义首页路径/(.*)\.html$ $1/404\.html
RewriteRule ^(.*)/templates/(.*)\.html$ $1/404\.html
RewriteRule ^(.*)/themes/自定义模板路径/(.*)\.html$ $1/404\.html
RewriteRule ^(.*)/modules/article/templates/$ $1/404\.html
RewriteRule ^(.*)/modules/article/templates/(.*)\.html$ $1/404\.html
RewriteRule ^(.*)/modules/article/templates/blocks/(.*)\.html$ $1/404\.html

1.8及2.2版本增加了区块调用模式,也就是大部分的数据调用代码不是写在模板文件,而是区块中的blocks定义文件里面,这种模式一定程度上防止盗取,但是终究也是有限的,以上就是伪静态写法。

规则之树版权所有,转载注明来源

当前页面是本站的「Baidu MIP」版。发表评论请点击:完整版 »