Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.Sign up
Tutorials: Mass re direction
Clone this wiki locally
Just as a refresher, I had asked:
Related to the above (but slightly off-topic), I’m wondering what folks are doing these days for mass re-direction? In the past, I’ve used a combination of mod_alias and mod_rewrite to ensure that links still work when launching a new site with different story URLs than it previously had. However, I’m wondering what other folks have done when needing to re-direct say 5000 old URLs to new ones?
And David had suggested:
“Most of our customers have written custom mod_rewrite scripts that look up the new → old mapping in a DB file for the redirection. I’ve also suggested creating dummy Bricolage stories for the old URIs, and have templates that just generate a simple page that does a REDIRECT_PERMANENT.”
Mixing all that together, I came up with this recipe:
- New Output Channel called htaccess with a file extension of htaccess
- New story type called Re-directs (might move that to a per category Cover-type story eventually)
- New template called htaccess that:
- Looks for stories with an “Old site URL” element in them (which folks have been entering as they go)
- Prints out the RedirectPermanent rule
- Prints out any “extra” stuff, like RedirectMatch rules that are entered right in the Re-direct story. This writes a /.htaccess file which does the trick.
At the moment, there’s no noticeable speed difference on our front- end server, and we’re using .htaccess files elsewhere (required by other applications) — so I suspect this will continue to work well into the 1000s or 10,000s of rules.
There you go! :-)