yidas/uri

带有自定义SEO设置的URL标准化重定向器

1.1.0 2018-01-25 04:04 UTC

This package is auto-updated.

Last update: 2024-09-10 21:03:50 UTC


README

带有自定义SEO设置的URL标准化重定向器

Latest Stable Version Latest Unstable Version License

演示

yidas\uri\Seo::trailingSlash(false)->removeIndex();

需求

此库需要以下内容

  • PHP 5.4.0+

安装

在您的项目中运行Composer

composer require yidas/uri

组件

Seo

yidas\uri\Seo 是处理SEO URI的辅助工具,您可以在应用程序中自定义设置规则,然后如果当前URI不符合您的期望,它将重定向到正确的URI。

使用方法如下

trailingSlash()

尾部斜杠处理器,默认情况下,它总是重定向到带有最后一个斜杠的URI。

https://www.domain.com/about/   (Switch On)
https://www.domain.com/about    (Switch Off)

例如

yidas\uri\Seo::trailingSlash(false);
// https://www.domain.com/about/ => https://www.domain.com/about

removeIndex()

大多数框架允许通过控制器根URI访问索引操作,这使其只能以这种方式访问。

例如,从 https://www.domain.com/about/index/https://www.domain.com/about/