skonsoft / redirector-bundle
一个用于重定向指定URL列表的symfony2包
dev-master
2013-06-28 23:20 UTC
Requires
- php: >=5.3.2
- symfony/framework-bundle: >=2.1,<2.4
This package is not auto-updated.
Last update: 2024-09-23 14:08:49 UTC
README
这是什么?
这是一个小巧但功能强大的包,它可以将您的旧页面URL重定向到新页面。您只需要用yaml格式编写配置重定向文件,例如
#app/config/redirected_urls.yml
url1:
from: "/first-url-to-redirect" #required
to: "/redirect-destination" #required
http_code: 301 #optionnal
host: http:/www.my-new-website.com #optionnal
url2:
from: "/articles/1220"
to: "/articles/how-to-write-a-redirected-file.html" #SEO optimization
http_code: 302
步骤1:使用composer安装包
{ "require": { // ... "skonsoft/redirector-bundle": "dev-master" } }
步骤2:注册包
<?php
// app/AppKernel.php
public function registerBundles()
{
$bundles = array(
// ...
new Skonsoft\Bundle\RedirectorBundle\SkonsoftRedirectorBundle(),
);
// ...
}
步骤3:编写配置重定向URL
在app/config目录下创建一个名为'redirected_urls.yml'的新文件,并将要重定向的URL保存到其中。请参考:资源/doc/redirected_urls.sample.yml
注意:您可以使用任何其他文件名和路径,只需在config.yml中覆盖'skonsoft_redirector.redirection_source_file'即可
#app/config.yml
parameters:
skonsoft_redirector.redirection_source_file: %kernel.root_dir%/config/redirected_urls.yml
步骤4:清除缓存
清除缓存并享受吧!