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

301 redirects from sub-directory content to root directory of new website on different domain & host.


Go to End


2 Posts   1416 Views

Avatar
Mitz

Community Member, 10 Posts

6 November 2014 at 10:15pm

Hi there,
I need to redirect pages from a sub-directory to the root directory of a new website with different domain name, host and site structure.
I can't get the htaccess file to work for me. The htaccess file did have a Rewrite base/subdirectory which I deleted because it may be in conflict.

It looks like this...

php_value post_max_size 40M
php_value upload_max_filesize 40M

### SILVERSTRIPE START ###
<Files *.ss>
#Order deny,allow
#Deny from all
#Allow from 127.0.0.1
Require valid-user
</Files>

RewriteEngine On
RewriteBase /

Redirect 301 subdirectory/ http://www.newdomainname.com.au
Redirect 301 subdirectory/page1 http://www.newdomainname.com.au/newpageurl
etc etc

RewriteCond %{REQUEST_URI} !(\.gif$)|(\.jpg$)|(\.png$)|(\.css$)|(\.js$)

RewriteCond %{REQUEST_URI} ^(.*)$
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule .* ss.php?url=%1&%{QUERY_STRING} [L]

#php_value memory_limit 128M

### SILVERSTRIPE END ###
#<Location /webdav>
#RewriteEngine Off
#</Location>

Would appreciate your help immensely! Thanks.

Avatar
codemonkey88

Community Member, 24 Posts

12 December 2014 at 6:17am

Edited: 12/12/2014 6:17am

If you still have SilverStripe installed, couldn't you just call

Director::redirect("http://www.newsite.com", 301);
in your init() function? Might be easier than messing around with htaccess