user3786012
user3786012

Reputation: 53

Silverstripe SEO URL - redirect

  1. How can I make SilverStripe always redirect to a URL with www.
    For example: Someone types in the url http://domain.de/about-us. They should be redirected to http://www.domain.de/about-us
    Is there a code for the _config.php to set the redirection?

  2. There are several domains for one project. How can I make SilverStripe always redirect to the main domain. For example: someone types in the url büüd.de/about-us -> they should always be redirected to the main domain www.bueued.de/about-us

Upvotes: 2

Views: 848

Answers (1)

munomono
munomono

Reputation: 1245

in _config.php

Director::forceWWW();

You also can set it per yml but since you have to flush before it takes effect, it can get ugly to disable it (manually delete silverstripe-cache) in cases when the www-domain does not work.

To use one domain I usually use a 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]

This post is related: SilverStripe. How to redirect from www.domainName to domainName?

Upvotes: 5

Related Questions