文档章节

dt二次开发之-url伪静态的自定义

o
 osc_4nmshwhm
发布于 2018/08/07 08:52
字数 1486
阅读 10
收藏 0
php

精选30+云产品,助力企业轻松上云!>>>

    dt内核的方便性在于代码内核完全开源,都可以根据自身需要进行优化整改,个人在这段时间的深入研究,发现这套内核的方便性,今天继续给大家分享下DT的url伪静态如何自定义函数。

    url自定义文件是在api/url.inc.php这个文件,dt7.0也是,下面我会一一介绍!

    dt6.0的改造:

  

<?php
defined('IN_DESTOON') or exit('Access Denied'); include load('include.lang');//引入语言文件 $urls = array();
$urls['htm']['list'][0] = array('example'=>'('.$L['url_htm'].') catdir/25.html','index'=>'{$catdir}/{$index}.{$file_ext}', 'page'=>'{$catdir}/{$prefix}{$page}.{$file_ext}'); $urls['htm']['list'][1] = array('example'=>'('.$L['url_htm'].') 10/25.html','index'=>'{$catid}/{$index}.{$file_ext}', 'page'=>'{$catid}/{$prefix}{$page}.{$file_ext}'); $urls['htm']['list'][2] = array('example'=>'('.$L['url_htm'].') 10_25.html','index'=>'{$prefix}{$catid}.{$file_ext}', 'page'=>'{$prefix}{$catid}_{$page}.{$file_ext}'); $urls['htm']['list'][3] = array('example'=>'('.$L['url_htm'].') '.$L['category'].'/1.html','index'=>'{$catname}/{$index}.{$file_ext}', 'page'=>'{$catname}/{$page}.{$file_ext}'); $urls['htm']['item'][0] = array('example'=>'('.$L['url_htm'].') 1/125.html','index'=>'{$alloc}/{$prefix}{$itemid}.{$file_ext}', 'page'=>'{$alloc}/{$prefix}{$itemid}_{$page}.{$file_ext}'); $urls['htm']['item'][1] = array('example'=>'('.$L['url_htm'].') 200810/25/125.html','index'=>'{$year}{$month}/{$day}/{$prefix}{$itemid}.{$file_ext}', 'page'=>'{$year}{$month}/{$day}/{$prefix}{$itemid}_{$page}.{$file_ext}'); $urls['htm']['item'][2] = array('example'=>'('.$L['url_htm'].') catdir/1/125.html','index'=>'{$catdir}/{$alloc}/{$prefix}{$itemid}.{$file_ext}', 'page'=>'{$catdir}/{$alloc}/{$prefix}{$itemid}_{$page}.{$file_ext}'); $urls['htm']['item'][3] = array('example'=>'('.$L['url_htm'].') 200810/'.$L['title'].'_125.html','index'=>'{$year}{$month}/{$title}_{$itemid}.{$file_ext}', 'page'=>'{$year}{$month}/{$title}_{$itemid}_{$page}.{$file_ext}'); $urls['htm']['item'][4] = array('example'=>'('.$L['url_htm'].') catdir/200810/125.html','index'=>'{$catdir}/{$year}{$month}/{$prefix}{$itemid}.{$file_ext}', 'page'=>'{$catdir}/{$year}{$month}/{$prefix}{$itemid}_{$page}.{$file_ext}'); $urls['htm']['item'][5] = array('example'=>'('.$L['url_htm'].') 200810/125.html','index'=>'{$year}{$month}/{$prefix}{$itemid}.{$file_ext}', 'page'=>'{$year}{$month}/{$prefix}{$itemid}_{$page}.{$file_ext}'); $urls['php']['list'][0] = array('example'=>'('.$L['url_php'].') list.php?catid=1&page=2','index'=>'list.php?catid={$catid}', 'page'=>'list.php?catid={$catid}&page={$page}'); $urls['php']['list'][1] = array('example'=>'('.$L['url_php'].') list.php/catid-1-page-2/','index'=>'list.php/catid-{$catid}/', 'page'=>'list.php/catid-{$catid}-page-{$page}/'); $urls['php']['list'][2] = array('example'=>'('.$L['url_rewrite'].') list-htm-catid-1-page-2.html','index'=>'list-htm-catid-{$catid}.html', 'page'=>'list-htm-catid-{$catid}-page-{$page}.html'); $urls['php']['list'][3] = array('example'=>'('.$L['url_rewrite'].') list-1-2.html','index'=>'list-{$catid}.html', 'page'=>'list-{$catid}-{$page}.html'); $urls['php']['list'][4] = array('example'=>'('.$L['url_rewrite'].') list/1/','index'=>'list/{$catid}/', 'page'=>'list/{$catid}/{$page}/'); $urls['php']['list'][5] = array('example'=>'('.$L['url_rewrite'].') mulu-c1-2.html','index'=>'{$catdir}-c{$catid}-1.html', 'page'=>'{$catdir}-c{$catid}-{$page}.html'); $urls['php']['item'][0] = array('example'=>'('.$L['url_php'].') show.php?itemid=1&page=2','index'=>'show.php?itemid={$itemid}', 'page'=>'show.php?itemid={$itemid}&page={$page}'); $urls['php']['item'][1] = array('example'=>'('.$L['url_php'].') show.php/itemid-1-page-2/','index'=>'show.php/itemid-{$itemid}/', 'page'=>'show.php/itemid-{$itemid}-page-{$page}/'); $urls['php']['item'][2] = array('example'=>'('.$L['url_rewrite'].') show-htm-itmeid-1.html','index'=>'show-htm-itemid-{$itemid}.html', 'page'=>'show-htm-itemid-{$itemid}-page-{$page}.html'); $urls['php']['item'][3] = array('example'=>'('.$L['url_rewrite'].') show-1-2.html','index'=>'show-{$itemid}.html', 'page'=>'show-{$itemid}-{$page}.html'); $urls['php']['item'][4] = array('example'=>'('.$L['url_rewrite'].') show/1/','index'=>'show/{$itemid}/', 'page'=>'show/{$itemid}/{$page}/'); ?>

  伪静态规则为:

   

#Rewrite Rules
ErrorDocument 404 /404.php
RewriteEngine On
RewriteRule ^(.*)\.(asp|aspx|asa|asax|dll|jsp|cgi|fcgi|pl)(.*)$ /404.php
RewriteRule ^(.*)/(admin|cache|editor|file|include|lang|module|skin|template)/(.*)\.php(.*)$ /404.php
RewriteRule ^(.*)-htm-(.*)$ $1.php?$2
RewriteRule ^(.*)/show-([0-9]+)([\-])?([0-9]+)?\.html$ $1/show.php?itemid=$2&page=$4
RewriteRule ^(.*)/list-([0-9]+)([\-])?([0-9]+)?\.html$ $1/list.php?catid=$2&page=$4
RewriteRule ^(.*)/([A-za-z0-9_\-]+)-c([0-9]+)-([0-9]+)\.html$ $1/list.php?catid=$3&catdir=$2&page=$4
RewriteRule ^(.*)/show/([0-9]+)/([0-9]+)?([/])?$ $1/show.php?itemid=$2&page=$3
RewriteRule ^(.*)/list/([0-9]+)/([0-9]+)?([/])?$ $1/list.php?catid=$2&page=$3
RewriteRule ^(.*)/([0-9]+)-([0-9]+)-([0-9]+)-([0-9]+)\.html$ $1/index.php?moduleid=$2&catid=$3&itemid=$4&page=$5
RewriteRule ^(.*)/([a-z]+)/(.*)\.shtml$ $1/$2/index.php?rewrite=$3
RewriteRule ^(com)/([a-z0-9_\-]+)/([a-z]+)/(.*)\.html$ index.php?homepage=$2&file=$3&rewrite=$4
RewriteRule ^(com)/([a-z0-9_\-]+)/([a-z]+)([/])?$ index.php?homepage=$2&file=$3
RewriteRule ^(com)/([a-z0-9_\-]+)([/])?$ index.php?homepage=$2
RewriteRule ^(.*)/kw-([A-za-z0-9]+)\.html$ $1/search.php?kw=$2

 6.0演示站点: http://zhimo.yuanzhumuban.cc/

 

  接下来演示7.0的伪静态自定义,7.0是手机端和PC端统一的路径,这个让人很欣慰。

    

<?php
defined('IN_DESTOON') or exit('Access Denied');
include load('include.lang');

$urls = array();

$urls['htm']['list'][0] = array('example'=>'('.$L['url_htm'].') catdir/25.html','index'=>'{$catdir}/{$index}.{$file_ext}', 'page'=>'{$catdir}/{$prefix}{$page}.{$file_ext}');
$urls['htm']['list'][1] = array('example'=>'('.$L['url_htm'].') 10/25.html','index'=>'{$catid}/{$index}.{$file_ext}', 'page'=>'{$catid}/{$prefix}{$page}.{$file_ext}');
$urls['htm']['list'][2] = array('example'=>'('.$L['url_htm'].') 10_25.html','index'=>'{$prefix}{$catid}.{$file_ext}', 'page'=>'{$prefix}{$catid}_{$page}.{$file_ext}');
$urls['htm']['list'][3] = array('example'=>'('.$L['url_htm'].') '.$L['category'].'/1.html','index'=>'{$catname}/{$index}.{$file_ext}', 'page'=>'{$catname}/{$page}.{$file_ext}');

$urls['htm']['item'][0] = array('example'=>'('.$L['url_htm'].') 1/125.html','index'=>'{$alloc}/{$prefix}{$itemid}.{$file_ext}', 'page'=>'{$alloc}/{$prefix}{$itemid}_{$page}.{$file_ext}');
$urls['htm']['item'][1] = array('example'=>'('.$L['url_htm'].') 200810/25/125.html','index'=>'{$year}{$month}/{$day}/{$prefix}{$itemid}.{$file_ext}', 'page'=>'{$year}{$month}/{$day}/{$prefix}{$itemid}_{$page}.{$file_ext}');
$urls['htm']['item'][2] = array('example'=>'('.$L['url_htm'].') catdir/1/125.html','index'=>'{$catdir}/{$alloc}/{$prefix}{$itemid}.{$file_ext}', 'page'=>'{$catdir}/{$alloc}/{$prefix}{$itemid}_{$page}.{$file_ext}');
$urls['htm']['item'][3] = array('example'=>'('.$L['url_htm'].') 200810/'.$L['title'].'_125.html','index'=>'{$year}{$month}/{$title}_{$itemid}.{$file_ext}', 'page'=>'{$year}{$month}/{$title}_{$itemid}_{$page}.{$file_ext}');
$urls['htm']['item'][4] = array('example'=>'('.$L['url_htm'].') catdir/200810/125.html','index'=>'{$catdir}/{$year}{$month}/{$prefix}{$itemid}.{$file_ext}', 'page'=>'{$catdir}/{$year}{$month}/{$prefix}{$itemid}_{$page}.{$file_ext}');
$urls['htm']['item'][5] = array('example'=>'('.$L['url_htm'].') 200810/125.html','index'=>'{$year}{$month}/{$prefix}{$itemid}.{$file_ext}', 'page'=>'{$year}{$month}/{$prefix}{$itemid}_{$page}.{$file_ext}');

$urls['php']['list'][0] = array('example'=>'('.$L['url_php'].') list.php?catid=1&page=2','index'=>'list.php?catid={$catid}', 'page'=>'list.php?catid={$catid}&page={$page}');
$urls['php']['list'][1] = array('example'=>'('.$L['url_php'].') list.php/catid-1-page-2/','index'=>'list.php/catid-{$catid}/', 'page'=>'list.php/catid-{$catid}-page-{$page}/');
$urls['php']['list'][2] = array('example'=>'('.$L['url_rewrite'].') list-htm-catid-1-page-2.html','index'=>'list-htm-catid-{$catid}.html', 'page'=>'list-htm-catid-{$catid}-page-{$page}.html');
$urls['php']['list'][3] = array('example'=>'('.$L['url_rewrite'].') list-1-2.html','index'=>'list-{$catid}.html', 'page'=>'list-{$catid}-{$page}.html');
$urls['php']['list'][4] = array('example'=>'('.$L['url_rewrite'].') list/1/','index'=>'list/{$catid}/', 'page'=>'list/{$catid}/{$page}/');
$urls['php']['list'][5] = array('example'=>'('.$L['url_rewrite'].') mulu-c1-2.html','index'=>'{$catdir}-c{$catid}-1.html', 'page'=>'{$catdir}-c{$catid}-{$page}.html');

$urls['php']['item'][0] = array('example'=>'('.$L['url_php'].') show.php?itemid=1&page=2','index'=>'show.php?itemid={$itemid}', 'page'=>'show.php?itemid={$itemid}&page={$page}');
$urls['php']['item'][1] = array('example'=>'('.$L['url_php'].') show.php/itemid-1-page-2/','index'=>'show.php/itemid-{$itemid}/', 'page'=>'show.php/itemid-{$itemid}-page-{$page}/');
$urls['php']['item'][2] = array('example'=>'('.$L['url_rewrite'].') show-htm-itmeid-1.html','index'=>'show-htm-itemid-{$itemid}.html', 'page'=>'show-htm-itemid-{$itemid}-page-{$page}.html');
$urls['php']['item'][3] = array('example'=>'('.$L['url_rewrite'].') show-1-2.html','index'=>'show-{$itemid}.html', 'page'=>'show-{$itemid}-{$page}.html');
$urls['php']['item'][4] = array('example'=>'('.$L['url_rewrite'].') show/1/','index'=>'show/{$itemid}/', 'page'=>'show/{$itemid}/{$page}/');
?>

  7.0伪静态规则

  

# xuetong365 Rewrite Rules
ErrorDocument 404 /404.php
RewriteEngine On
RewriteRule ^(.*)\.(asp|aspx|asa|asax|dll|jsp|cgi|fcgi|pl)(.*)$ /404.php
RewriteRule ^(admin|cache|file|include|lang|module|skin|template|skin)/(.*)\.php(.*)$ /404.php
RewriteRule ^(.*)-htm-(.*)$ $1.php?$2
RewriteRule ^(.*)/show-([0-9]+)([\-])?([0-9]+)?\.html$ $1/show.php?itemid=$2&page=$4
RewriteRule ^(.*)/list-([0-9]+)([\-])?([0-9]+)?\.html$ $1/list.php?catid=$2&page=$4
RewriteRule ^(.*)/([A-za-z0-9_\-]+)-c([0-9]+)-([0-9]+)\.html$ $1/list.php?catid=$3&catdir=$2&page=$4
RewriteRule ^(.*)/show/([0-9]+)/([0-9]+)?([/])?$ $1/show.php?itemid=$2&page=$3
RewriteRule ^(.*)/list/([0-9]+)/([0-9]+)?([/])?$ $1/list.php?catid=$2&page=$3
RewriteRule ^(.*)/([0-9]+)-([0-9]+)-([0-9]+)-([0-9]+)\.html$ $1/index.php?moduleid=$2&catid=$3&itemid=$4&page=$5
RewriteRule ^(.*)/([a-z]+)/(.*)\.shtml$ $1/$2/index.php?rewrite=$3
RewriteRule ^(com)/([a-z0-9_\-]+)/([a-z]+)/(.*)\.html$ index.php?homepage=$2&file=$3&rewrite=$4
RewriteRule ^(com)/([a-z0-9_\-]+)/([a-z]+)([/])?$ index.php?homepage=$2&file=$3
RewriteRule ^(com)/([a-z0-9_\-]+)([/])?$ index.php?homepage=$2
RewriteRule ^(.*)/search-htm-kw-([A-za-z0-9]+)\.html$ $1/search.php?kw=$2

  演示站点:http://www.xuetong365.com/

   

o
粉丝 0
博文 500
码字总数 0
作品 0
私信 提问
加载中
请先登录后再评论。

暂无文章

如何将div放置在其容器的底部? - How can I position my div at the bottom of its container?

问题: Given the following HTML: 鉴于以下HTML: <div id="container"> <!-- Other elements here --> <div id="copyright"> Copyright Foo web designs </div> </div> I would like #cop......

富含淀粉
51分钟前
10
0
unity列表控件Horizontal/Vertical/Grid Layout Group用法介绍

1. Grid Layout Group 为Panel控件添加Grid Layout Group,子控件为四个按钮,分别为Grid,Calendar,Gear,User: 默认属性为 为方便演示,按钮的底色为控件自带image,按钮上面的图标为其子...

路过暴风
今天
19
0
Distinct()与lambda? - Distinct() with lambda?

问题: Right, so I have an enumerable and wish to get distinct values from it. 是的,所以我有一个可枚举的,并希望从中获得不同的值。 Using System.Linq , there's of course an ext......

法国红酒甜
今天
16
0
学习编写编译器[关闭] - Learning to write a compiler [closed]

问题: Preferred languages : C/C++, Java, and Ruby. 首选语言 :C / C ++,Java和Ruby。 I am looking for some helpful books/tutorials on how to write your own compiler simply for......

技术盛宴
今天
17
0
OSChina 周一乱弹 —— 毛巾又怎么样?!我在乎的是大姐姐温柔的怀抱!

Osc乱弹歌单(2020)请戳(这里) 【今日歌曲】 @薛定谔的兄弟 :分享洛神有语创建的歌单「我喜欢的音乐」: 《雨 因你而下,于你而止》- Seto 手机党少年们想听歌,请使劲儿戳(这里) @Dan...

小小编辑
今天
48
2

没有更多内容

加载失败,请刷新页面

加载更多

返回顶部
顶部