【问题标题】:Silverstripe SEO URL - redirectSilverstripe SEO URL - 重定向
【发布时间】:2015-01-07 22:38:23
【问题描述】:
  1. 如何让 SilverStripe 始终重定向到带有 www 的 URL。
    例如:有人输入网址http://domain.de/about-us。他们应该被重定向到 http://www.domain.de/about-us
    _config.php 有设置重定向的代码吗?

  2. 一个项目有多个域。如何使 SilverStripe 始终重定向到主域。例如:有人输入网址 büüd.de/about-us -> 他们应该始终被重定向到主域 www.bueued.de/about-us

【问题讨论】:

    标签: .htaccess url redirect seo silverstripe


    【解决方案1】:

    在_config.php中

    Director::forceWWW();
    

    您也可以按 yml 设置它,但由于您必须在它生效之前刷新,因此在 www 域不起作用的情况下禁用它(手动删除 silverstripe-cache)可能会变得很难看。

    要使用一个域,我通常使用 htaccess-rule。

    RewriteCond %{HTTP_HOST} ^domain1.com [NC,OR]
    RewriteCond %{HTTP_HOST} ^domain2.com [NC,OR]
    RewriteCond %{HTTP_HOST} ^domain3.com [NC,OR]
    RewriteCond %{HTTP_HOST} ^domain4.com [NC]
    RewriteRule ^(.*)$ http://newdomain.ch/$1 [r=301,L]
    

    这篇文章是相关的: SilverStripe. How to redirect from www.domainName to domainName?

    【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2018-04-28
    • 2012-05-22
    • 1970-01-01
    • 1970-01-01
    • 2011-12-17
    • 2015-05-29
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多