astina/redirect-manager-bundle

此包已被废弃,不再维护。作者建议使用origammi/redirect-manager-bundle包。

用户可以通过Web GUI指定重定向。

安装次数:71,856

依赖关系: 0

建议者: 0

安全性: 0

星标: 6

关注者: 19

分支: 8

类型:symfony-bundle

3.5.1 2023-07-24 05:40 UTC

This package is auto-updated.

Last update: 2023-07-24 05:43:50 UTC


README

Build Status Latest Stable Version Total Downloads SensioLabsInsight

安装

步骤 1:添加到 composer.json

"require" :  {
    // ...
    "astina/redirect-manager-bundle":"dev-master",
}

步骤 2:启用包

在内核中启用包

<?php
// app/AppKernel.php

public function registerBundles()
{
    $bundles = array(
        // ...
        new Astina\Bundle\RedirectManagerBundle\AstinaRedirectManagerBundle(),
    );
}

步骤 3:导入路由文件

导入包的路由文件。根据需要更改前缀属性。

在 YAML 中

# app/config/routing.yml
astina_redirect_manager:
    resource: "@AstinaRedirectManagerBundle/Resources/config/routing.yml"
    prefix:   /redirect/

步骤 4:翻译

如果您想使用本包提供的默认文本,请确保您的配置中启用了翻译器。

# app/config/config.yml

framework:
    translator: ~

步骤 5:配置选项

在具有多个实体管理器的应用程序中,请配置一个新的管理器或确保默认管理器可以访问模式。

# app/config/config.yml
astina_redirect_manager:
    storage:
      entity_manager: redirect # Optional entity manager name, if ommitted default entity manager is used
    base_layout: "SomeBundle:SomeDir:index.html.twig"    # Override default Astina layout
    enable_listeners: false # Set to false to disable redirect listeners. Useful for service oriented architectures. Defaults to true

步骤 6:更新您的数据库模式

$ php app/console doctrine:schema:update --force

用法

使用命令导入URL

此包知道如何导入用于重定向的URL csv文件。CSV必须包含两列,其中第一列包含urlFrom,第二列包含urlTo。

$ php app/console armb:import /path/to/csv/file.csv [--redirect-code=302] [--count-redirects]

使用子域名监听器将用户重定向到其他地方

如果监听器检测到使用了子域名,它将访问者重定向到具有名称 route_nameroute_params 和重定向代码 redirect_code 的URL。

# app/config/config.yml

astina_redirect_manager:
    redirect_subdomains:
        route_name:           ~ # Required
        route_params:
            param1: some-value
            param2: some-different-value
        redirect_code:        301

警告

您必须在 parameters.yml 文件中设置参数 router.request_context.host。否则将使用 localhost 作为域名。

# app/config/parameters.yml

# ...
router.request_context.host: example.com
# ...