If you are going live with a new website, you want to ensure you do not loose any visitors due to changed URLs structure. This is where URL rewriting comes with help. All you need is a simple set of directives in htaccess file:
Redirect 301 /Contact_Us.aspx http://www.mydomain.com/contact |
If you have many pages on your websites, writing rules for all matching URLs might take hours. Here is how you can make your life easier. You can prepare a CSV file with two columns – in first you will keep URLs on old website, in second you add matching URLs on new website. Then you can run the following script and simply add the output to your htaccess file:
require 'csv' DOMAIN="www.mydomain.com" URLSFILE="myurls.csv" CSV.open(URLSFILE, 'r') do |row| puts "Redirect 301 "+row[0].gsub(/http:\/\/#{DOMAIN}/, "")+" #{row[1]}" end |
The post URL rewriting when going live appeared first on SEO Consultant London (UK).