I'm currently having problems implementing 301 page redirects on the htaccess file associated with a Silverstripe 2.4.5 install. I've rebuilt a client's old asp based website in Silverstripe and the site has a number of old page references on the search indexes.
The current htaccess file has the following in place:
### SILVERSTRIPE START ###
<Files *.ss>
Order deny,allow
Deny from all
Allow from 127.0.0.1
</Files>
<Files web.config>
Order deny,allow
Deny from all
</Files>
ErrorDocument 404 /assets/error-404.html
ErrorDocument 500 /assets/error-500.html
<IfModule mod_alias.c>
RedirectMatch 403 /silverstripe-cache(/|$)
</IfModule>
<IfModule mod_rewrite.c>
SetEnv HTTP_MOD_REWRITE On
RewriteEngine On
RewriteCond %{REQUEST_URI} ^(.*)$
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule .* sapphire/main.php?url=%1&%{QUERY_STRING} [L]
</IfModule>
### SILVERSTRIPE END ###
I've looked at a few forum posts on htaccess files and 301 redirect problems and tried placing the following RewriteCond on the Silverstripe htaccess file:
RewriteRule ^news.asp http://www.mydomain.co.uk/news-and-events/latest-news/ [R=301,NC,L]
Placing the above code at the end of the RewriteRule produced no redirect result on the public page, just a 404 page error ie
... RewriteRule .* sapphire/main.php?url=%1&%{QUERY_STRING} [L]
RewriteRule ^news.asp http://www.mydomain.co.uk/news-and-events/latest-news/ [R=301,NC,L]
</IfModule>
### SILVERSTRIPE END ###
and placing the code before the Silverstripe copy gave the desired page redirect but the main site navigation links broke? ie
RewriteRule ^news.asp http://www.mydomain.co.uk/news-and-events/latest-news/ [R=301,NC,L]
### SILVERSTRIPE START ###
<Files *.ss>
Order deny,allow ...
Has anyone experienced the same issue with 301 redirects and this type of Silverstripe htaccess file? Any suggestions appreciated!
Matt