typecho 重定向
以前台注册为例,他是一个独立页,所以输入地址是可以直接进入的,但是如果用户已经登录了,按道理,这个页面是不能进的,所以需要重定向。
于是乎我们需要在开头加上这么一句话
if ($this->user->hasLogin()) {
header("Location:".$this->options->siteUrl);
exit;
}
这里以独立页做个演示:
<?php
/**
* register
*
* @package custom
*/
if (!defined('__TYPECHO_ROOT_DIR__')) exit;
if ($this->user->hasLogin()) {
header("Location:".$this->options->siteUrl);
exit;
}
?>
我们在开头的头信息处做这个即可。
分类:
Typecho博客教程
标签:
typecho
版权申明
本文系作者 @木灵鱼儿 原创发布在木灵鱼儿站点。未经许可,禁止转载。
评论
最新文章
如何在项目中使用一个自定义的npm模块(如何使用一个魔改后的npm模块)
0点赞
·
1评论
Debian12 更新系统版本(目前更新至12.5版本)
0点赞
·
0评论
Nestjs CORS配置和生产环境处理
1点赞
·
0评论
Debian12 SSH连接报错:Error Handshake failed no matching host key format
0点赞
·
0评论
Prisma 使用MongoDB创建数据时报错:Prisma needs to perform transactions, which requires your MongoDB server to be run as a replica set.
0点赞
·
0评论
目录
暂无目录
暂无评论数据