承接 truecastdesign/jsonredirects 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

truecastdesign/jsonredirects

Composer 安装命令:

composer require truecastdesign/jsonredirects

包简介

Json file based redirects with exact match and wildcard * matching for changing higher up paths with sub categories so the sub categories get redirected as well.

README 文档

README

Json file based redirects with exact match and wildcard * matching for changing higher up paths with sub categories so the sub categories get redirected as well.

Use

Truecast\Redirects::redirect(['request'=>$_SERVER['REQUEST_URI'], 'lookup'=>BP.'/redirects.json', 'type'=>'301']);

JSON File

{
	"path1/path2/":"path3/",
	"path4/path5/*":"path4/path6/*",
	"path7/path9/*":"path7/path10/",
}

First line: Simple redirect. Key: request uri and value: redirected uri

Second line: Matches "path4/path5/path8/" redirects to "path4/path6/path8/" The path that matches the * on the request is moved over to the end of the redirect uri in place of the *

Third line: Matches "path7/path9/path8/" redirects to "path7/path10/" The path that matches the * on the request is NOT moved over to the end of the redirect uri because there is no * on the redirect

Editing JSON file with PHP

Add redirect

$Redirects = new App\Redirects(BP.'/config/redirects.json');
$Redirects->add($App->request->post->fromUrl, $App->request->post->toUrl);

Remove redirect

$Redirects = new App\Redirects(BP.'/config/redirects.json');
$Redirects->remove($App->request->delete->fromUrl);

Get redirects list

$Redirects = new App\Redirects(BP.'/config/redirects.json');
$list = $Redirects->getRedirectsList();

// array ['from-url'=>'to-url', 'from-url'=>'to-url']

Clean URL

$Redirects = new App\Redirects(BP.'/config/redirects.json');
$cleanedURL = $Redirects->cleanUrl($url);

Notes

This code works well in a routes script at the top before other custom routes are checked.

It is only designed to match the end of the url and not a middle part like path/*/path If that would be helpful, let me know and I will see what I can do.

Thanks!

I hope this is helpful.

统计信息

  • 总下载量: 12
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 1
  • Forks: 1
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2019-03-29

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固