genj / short-url-bundle
此包已被废弃,不再维护。未建议替代包。
Symfony Short Url 扩展包
v1.0.4
2015-08-31 13:58 UTC
Requires
- gedmo/doctrine-extensions: ~2.3
- sensio/framework-extra-bundle: ~3.0
- symfony/symfony: >=2.5,<3.0-dev
This package is not auto-updated.
Last update: 2024-02-17 13:50:43 UTC
README
提供基于数据库中存储的实体进行请求重定向的方法。特性
- 基于请求路径重定向客户端,例如 '/something'
- 内部和外部重定向到路径或URL
- 有开始/结束时间
- 可配置的HTTP状态码
- 重定向时保留查询字符串参数
安装
将此添加到您的 composer.json 中
...
"require": {
...
"genj/short-url-bundle": "dev-master"
...
然后运行 composer update
。完成后,在 AppKernel.php 中启用此扩展包
# app/AppKernel.php
class AppKernel extends Kernel
{
public function registerBundles() {
$bundles = array(
...
new Genj\ShortUrlBundle\GenjShortUrlBundle()
...
最后,更新您的数据库模式
php app/console doctrine:schema:update
完成。
使用方法
向您的数据库添加一条新记录。示例
- 源: /my-old-url
- 目标: /my-new-url
- httpStatusCode: 301
- publishAt: (now)
常见问题解答
我的重定向在 app.php 中不起作用,但在 app_dev.php 中起作用
如果您启用了缓存,可能发生的情况是404响应被存储在http缓存中,因此请清除您的缓存。重定向请求本身有私有缓存头。