Marketing_Guy - 2:14 pm on Mar 8, 2013 (gmt 0)
Spent the past few hours reading up on old posts, trying to figure out a problem. I've been tasked with sorting out old > new redirects for a large site and dealing with some legacy issues (2 previous URL structures and no real consistent format to the new / 3rd).
The client's old developer stuck 10k or so one to one Redirect Permanent rules into their htaccess file, which with along with other stuff brings it to 1.2mb in size. My knowledge of these things is pretty limited, but I'm guessing that isn't doing them any favours in terms of server performance and could be managed much better. Performance aside, some of the version 1 URLs haven't been redirected so the client is losing out on a lot of old inbound link juice (their new site launch at the end of the year saw their rankings plummet because of this and other issues).
The site is split into 80 or so locations - the plan is to redirect all old pages (version 1 and version 2 URLs) to the hub page of each location. Each location is available in up to 9 languages so redirects are to language appropriate hub pages.
The two old URL formats were:
The new CMS doesn't use .cfm pages, so the idea is to grab any request for .cfm pages and redirect to the appropriate hub page (main landing page for the location), the structure for which is:
(this format is correct for all languages except German and French, where "overview" is replaced with "uebersicht" and "apercu" respectively).
The rule I've come up with so far is:
RewriteRule ^/en/pub/[^/]+/worldmap/LOCATION1/[^/]+\.cfm /en/continent/country/location2/brand-term/overview/ [R=301,L]
RewriteRule ^/fr/pub/[^/]+/worldmap/LOCATION1/[^/]+\.cfm /fr/continent/country/location2/brand-term/apercu/ [R=301,L]
However, this would require creating the rule for each location and each language (~800 lines, which is still better than the current 10k+, but far from ideal).
I would like to be able to reduce this to the bare minimum, but my regex knowledge is holding me back. :)
Some questions & points
RewriteRule ^/([^/]+)/pub/[^/]+/worldmap/LOCATION1/[^/]+\.cfm /$1/continent/country/location2/brand-term/overview|apercu|uebersicht/ [R=301,L]