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 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

Problem with 301 in htacess

Go to End

3 Posts   1500 Views


Community Member, 12 Posts

10 June 2015 at 11:30pm

Edited: 10/06/2015 11:32pm

I am trying to set up a very simple redirect which for some reason I just cannot get working. After a complete overhaul of the website, the new About page has the url /about-us/ whereas the old site was /aboutus/ . As google is still indexing the old url I wanted to set up a redirect from /aboutus/ to /about-us/ but nothing is working. I will need to set up a few of these rules pointing the old indexed pages to pages on the new website.
I have tried the following redirect rules:

RewriteRule ^/aboutus /about-us [R=301,NC,L]
Redirect 301 /aboutus /about-us

But both of these cause the site to redirect to the following url "" which brings up a "Page not found" error.

Seems like it is working fine aside from the "?url=" part of the url which is causing the problems. Anyone encountered this before?

Many thanks,


Community Member, 130 Posts

11 June 2015 at 5:57am

Mine look like this:

RewriteRule ^aboutus [R=301,L]

And it needs to be above the ### SILVERSTRIPE START ### section. I think your ?url= part is being added in that section so maybe you need to move your directive higher?

Fred Condo

Community Member, 29 Posts

12 June 2015 at 5:35am

This is due to a "feature" of apache .htaccess files, in which the prefix of the path to the containing directory of the .htaccess file is stripped from paths. In the case of the main .htaccess file, this means that the initial / is removed. That's why JonoM's paths lack the /.

My practice was to write paths, which are regexes, like so: ^/?foo-bar — this makes them portable between .htaccess and the main server configuration.

I actually use nginx exclusively these days.