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.
14 Posts 2981 Views
We recently changed our site to SilverStripe. But as we search with a keyword in Google, we still seeing a lot of old url's.
How can I change them. exp.:
/products.asp?productgroupid=5&language=nl to the /products?
I've seen a lots of posts where they suggest to work with a .htaccess file, but that doesnt work.
weird, I came here to ask the same question.
basically I want to do a redirect before the rewrite rule takes effect.
so if my old site was "mysite.com/old/page"
I want to first have that resolve to "mysite.com/new/page"
the way I see it there should be two steps
1) turn the request for "mysite.com/old/page" into a request for "mysite.com/new/page"
2) the htaccess rewrite rules takes "mysite.com/new/page" and performs as usual
how does one do this? surely there must be some sort of .htaccess voodoo to accomplish it?
Just put the rewrite-rules before any SilverStripe rules, but after
RewriteBase (if that exists in your setup).
RewriteRule ^products.asp$ /products[R=301,QSA,L]
# SilverStripe Rewrites go here
This will redirect products.asp to /products.. the
QSA option tells the rewrite Engine to keep the query string (eg. ?productgroupid=5&language=nl)
wow, I tried this numerous ways yesterday and never got it quite right. I'd have the wrong url with the right content, the right url with the wrong content, totally new weird urls that I didn't intend. anyway, this works, I owe you a beer!
QSA was what I was missing all along.
Should you still have a 404 error page in SilverStripe? Because I still got the 404 error page, even if I add that code in my .htaccess file
FYI, here is a useful tweak if you want to direct sub directories
RewriteRule ^old/(.*)$ /new/$1 [R=301,QSA,L]
so mysite.com/old/page now goes to mysite.com/new/page