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.

General Questions /

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

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

[SOLVED] SS3 - 301 redirect problem


Reply


3 Posts   545 Views

Avatar
Optic Blaze

Community Member, 162 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, 137 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, 162 Posts

9 January 2013 at 10:50am

Thanks that worked!