Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

We've moved the forum!

Please use forum.silverstripe.org for any new questions (announcement).
The forum archive will stick around, but will be read only.

You can also use our Slack channel or StackOverflow to ask for help.
Check out our community overview for more options to contribute.

General Questions /

General questions about getting started with SilverStripe that don't fit in any of the categories above.

Moderators: martimiz, Sean, Ed, biapar, Willr, Ingo, swaiba

[SOLVED] SS3 - 301 redirect problem


Go to End


3 Posts   1291 Views

Avatar
Optic Blaze

Community Member, 190 Posts

9 January 2013 at 8:51am

Edited: 09/01/2013 8:54am

Hi there,

I have a website that i am doing SEO on and i need both www.diveschoolcapetown.co.za and http://diveschoolcapetown.co.za to point to http://www.diveschoolcapetown.co.za

I have changed the .htaccess file as follows:

<IfModule mod_rewrite.c>
.....
RewriteCond %{HTTP_HOST} ^diveschoolcapetown.co.za[nc]
RewriteRule ^(.*)$ http://www.diveschoolcapetown.co.za/$1 [r=301,nc]
.....
</IfModule>

The problem that i have is that it does not redirect correctly.
When i type in 'http://www.diveschoolcapetown.co.za' the url gets displayed as --- 'http://www.diveschoolcapetown.co.za/?url=/'

If i type in a nested url eg 'http://www.diveschoolcapetown.co.za/contactus' it does not redirect at all.

Please help

Avatar
Nobrainer Web

Community Member, 138 Posts

9 January 2013 at 10:09am

You can just add Director::forceWWW(); to your mysite/_config.php (I only use 2.4 but i think it will work in ss3 also)

Or if you want to use htaccess, use the below right after RewriteBase /

RewriteCond %{HTTP_HOST} !^(www\.)diveschoolcapetown\.co\.za$ [NC]
RewriteRule ^(.*)$ http://www.diveschoolcapetown.co.za/$1 [L,R=301]

Hope it helps

Avatar
Optic Blaze

Community Member, 190 Posts

9 January 2013 at 10:50am

Thanks that worked!