wecenter4.1版本定时任务中生成伪静态链接方法

君笑尘
君笑尘 This guy is lazy,Introduction has not been set

0 People liked this article · 594 views

wecenter4.1版本定时任务中,无法使用url()生成伪静态链接。跟官方沟通后,是因为

定时任务入口没有调用thinkphp的核心路由方法。可以在think文件中定义路由规则进行路由重写

所以我们只需要修改网站根目录(不是运行目录)下的think文件。添加路由重写规则即可。

复制一下代码,覆盖到think的内容。如果你有修改过路由规则,则需要进行对应的修改

#!/usr/bin/env php
<?php
namespace think;
define('DS', DIRECTORY_SEPARATOR);
define('ROOT_PATH', dirname(__DIR__) . DS);
define('ONE_DAY',86400);
define('ENTRANCE','frontend');
// 命令行入口文件
// 加载基础文件
require __DIR__ . '/vendor/autoload.php';
// 应用初始化
$console = (new App())->console;

\think\facade\Route::rule('questions/[:sort]-[:category_id]', 'question/index');
\think\facade\Route::rule('question/:id', 'question/detail');
\think\facade\Route::rule('articles/[:sort]-[:category_id]', 'article/index');
\think\facade\Route::rule('article/:id', 'article/detail');
\think\facade\Route::rule('columns/[:sort]', 'column/index');
\think\facade\Route::rule('column/:id', 'column/detail');
\think\facade\Route::rule('topics/[:type]-[:pid]', 'topic/index');
\think\facade\Route::rule('topic/:id', 'topic/detail');
\think\facade\Route::rule('people/:name/[:type]', 'people/index');
\think\facade\Route::rule('peoples/[:page]', 'people/lists');

$response = $console->run();


Published on 2023-07-01 09:30

Disclaimers:

This document is written by 君笑尘 Original published on 君笑尘的站长朋友 ,The copyright belongs to the author。

Log in,More exciting content waiting for you to find,Contribute wonderful answers,Participate in comment interaction

go Sign in! No accountgoregister

Recommended content

文章目录

客服QQ:21407787

服务时间 09:00-18:00

服务热线

13800138000

价格和优惠

获取内部资料

了解最新功能和特性

扫码加好友

All Rights Reserved Powered BY WeCenter V4.1.0 © 2025