Redirect old URLs to new Symphony site
This is an open discussion with 23 replies, filed under Troubleshooting.
Search
Nils, you don’t need to change the Symphony part of your .htaccess
file. Additional rules like global domain rewrites or rewrites for legacy URLs can be put at the beginning of the .htaccess
fiel (i.e. before the Symphony part). Here is an example:
<IfModule mod_rewrite.c> RewriteEngine on RewriteBase / ### global rewrite RewriteCond %{HTTP_HOST} !^www.mydomain.com$ [NC] RewriteRule ^(.*)$ http://www.mydomain.com/$1 [R,L] ### legacy URLs RewriteRule ^foo/$ /foostuff/foo/ [R,L] RewriteRule ^bar/(.*)$ /bar/stuff/$1 [R,L] </IfModule> ### Symphony 2.0.x ### ...
The first legacy URL rule will rewrite a single page (including a trailing slash).
The second will rewrite a whole “directory structure”.
You won’t break anything if you don’t redirect pages which actually exist in your new website. Just make sure to check your redirected URLs with and without trailing slashes. (If you don’t have the trailing slash rule included in your Symphony rewrite, you might omit the trailing slashes in the example if necessary, but keep in mind that an expression like ^foo(.*)
would also fit URLs like ^foobar
.)
Michael, thank you so much!
You’re welcome!
I usually add my rules just above Symphony’s rules, e.g.
### Amazon S3 bucket: http://bekonscot.co.uk.s3.amazonaws.com, Cloudfront distribution: http://d1jj4tnm2c6yqi.cloudfront.net, CNAME media.bekonscot.co.uk RewriteRule ^assets/files/(.*)$ http://media.bekonscot.co.uk/files/$1 [L] RewriteRule ^assets/images/home-(.*)$ http://media.bekonscot.co.uk/images/home-$1 [L] RewriteRule ^assets/swf/(.*)$ http://media.bekonscot.co.uk/swf/$1 [L] RewriteRule ^times_and_prices(.+) /plan-your-visit/ [R=301,L] RewriteRule ^map_and_location(.+) /plan-your-visit/map-and-directions/ [R=301,L] RewriteRule ^facilities(.+) /plan-your-visit/facilities/ [R=301,L] RewriteRule ^group_visits(.+) /plan-your-visit/group-visits/ [R=301,L] RewriteRule ^birthday_parties(.+) /plan-your-visit/birthday-parties/ [R=301,L] RewriteRule ^schools(.+) /plan-your-visit/school-visits/ [R=301,L] RewriteRule ^models/ /models-and-attractions/villages/ [R=301,L] RewriteRule ^gardens(.+) /models-and-attractions/gardens/ [R=301,L] RewriteRule ^model_railway(.+) /models-and-attractions/model-railway/ [R=301,L] RewriteRule ^ride_on(.+) /models-and-attractions/light-railway/ [R=301,L] RewriteRule ^behindscenes(.+) /behind-the-scenes/ [R=301,L] RewriteRule ^archive/ /history/ [R=301,L] RewriteRule ^products/ /shop/ [R=301,L] RewriteRule ^virtual_village/ /fun-and-games/virtual-village/ [R=301,L] RewriteRule ^downloads/ /fun-and-games/wallpapers/ [R=301,L] RewriteRule ^ecards/ /fun-and-games/ecards/ [R=301,L] RewriteRule ^contact_us(.+) /contact/ [R=301,L]
Damn, I forgot the 301
stuff in my example. This is a good thing for search engines!
This helped me a lot. I used this to handle existing or missing trailing slashs:
RewriteRule ^anfragen\/?$ /informieren/kontakt/ [R=301,L]
Looks cool, Nils!
So what kind of rules should I be using for a domain if the structure of pages has changed.. i.e google has chached info about pages that existed before the symphony build and when a user clicks on a link that has a url like http://www.domain.co.uk/jobs/php?j=p&s=0
Is there a way of re-directing these links to the root of the site if the url does not exist anymore? what is the 301 rule for?
You’d probably want to use a 404 for pages that don’t exist anymore, no?
So the 404 within symphony right now just throws the error that it couldn’t compile the xslt
XSLT Processing Error
This page could not be rendered due to the following XSLT processing errors.
What could be wrong?
Do you have a page with the page type ‘404’? Have you written its page template?
What could be wrong?
a) make sure you have a Symphony page with the type 404
b) make sure it has template content (a blank Symphony page’s template will give an error)
No worries.. sorted it now..
Datasource and templates weren’t attached.. all good now.. using the 404 styled like the rest of the site to display an error but still giving access to the navigation!
what is a 301 though?
301 means the redirect is permanent.
So google benefits from knowing this info? i.e documents that the previously cached data has permanently moved to the new location?
Yes
[ To my knowledge ] In this case you’d want to go 301, because the page does “exist” its just in another place. Google will update its records off of a 301, and old bookmarks don’t need to break. 404 penalizes users for trying to visit a door that used to work. I say make users happy :P
I found that the URL structure for a site that we are relaunching with Symphony could be quickly emulated with a template to write RewriteRule
configuration directives:
<xsl:for-each select="/data/team/entry"> <xsl:sort select="member" /> <xsl:text> RewriteRule ^Results/</xsl:text><xsl:value-of select="translate(member, ' ', '')" /><xsl:text>.html </xsl:text> <xsl:text>/team/</xsl:text><xsl:value-of select="member/@handle" />/ [R=301,L]<xsl:text> </xsl:text> </xsl:for-each>
Which will output something like this:
RewriteRule ^Team/ShawnNeumann.html /team/shawn-neumann/ [R=301,L] RewriteRule ^Team/StephenBau.html /team/stephen-bau/ [R=301,L]
Kinda cool.
How would you implement that Stephen?
Create an account or sign in to comment.
I have a list of old website URLs that should be redirected to the new URLs scheme of a redesigned website. I know the old links and I know the new ones. But I’m not a
mod_rewrite
expert: How do I add my list of old and new URLs to the main Symphony.htaccess
without breaking the whole system?Thanks for your help,
Nils