-
Notifications
You must be signed in to change notification settings - Fork 19
Redirecting RG1 to RG2
Simon Errington edited this page May 11, 2014
·
2 revisions
It is possible to redirect existing links from RG1 to RG2 using a .htaccess file. The following rules work successfully for the routegadget.co.uk installation, but as ever with this sort of thing you probably need to test it quite carefully.
RewriteCond %{HTTP_HOST} ^([a-z.]+)?routegadget\.co\.uk$ [NC]
RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteRule .? http://www.%1routegadget.co.uk%{REQUEST_URI} [R=301,L]
# if a deliberate call to RG1reitti remove RG1
RewriteRule (.*)/RG1reitti(.*) $1/reitti$2 [NC,L]
# if a call to RG1
RewriteCond %{REQUEST_URI} /reitti\.cgi [NC]
# and not originally a call to RG1reitti
RewriteCond %{THE_REQUEST} !(/RG1reitti) [NC]
# and query string exists and matches act=map&id=NNN&kieli=
RewriteCond %{QUERY_STRING} ^act=map\&id=([0-9]+)\&kieli=$ [NC]
# pass event id to rg2: NE prevents # turning into %23; R forces redirect; L stops processing further rules
RewriteRule .* /rg2#%1? [R=301,NE,NC,L]
# call to RG1 with no parameters: display RG1 index page
RewriteCond %{REQUEST_URI} /reitti\.cgi [NC]
# and not originally a call to RG1reitti
RewriteCond %{THE_REQUEST} !(/RG1reitti) [NC]
# no query string
RewriteCond %{QUERY_STRING} ^$ [NC]
# redirect to RG2 index page
RewriteRule .* /rg2 [R=301,NC,L]
The result of the above should be that:
- All links to the old RG1 index page (ending reitti.cgi) now automatically redirect to the RG2 index page.
- All links to an RG1 event (with format reitti.cgi?act=map&id=XXX&kieli=) now automatically redirect to that event in RG2.
This may cause problems for people who can't get RG2 to run. The best solution is to upgrade your browser. The workarounds are:
-
for the index page change reitti.cgi to RG1reitti.cgi, so for example http://www.happyherts.routegadget.co.uk/cgi-bin/RG1reitti.cgi
-
for a specific event change reitti.cgi to RG1reitti.cgi, so for example use http://www.happyherts.routegadget.co.uk/cgi-bin/RG1reitti.cgi?act=map&id=156&kieli=