I need to migrate my old site URLs (ending with .aspx/asp and these are a few hundreds) to new site (ending with .jsp/servlets).
We've opted to use RedirectMap
and RedirectRule
to implement this migration in Apache. The plain URLS are working fine. But case-sensitivity in the source URL is causing redirecting to a PAGENOTFOUND (For example, /magazine/Magazine.aspx?Id=4 is redirecting to PAGENOTFOUND
instead of http://mydomain.com/advice/beauty).
Another issue is that it is unable to redirect the the source URLs with a query string (for example, /Help/Help.aspx?HelpID=6 is redirecting to PAGENOTFOUND
instead of http://mydomain.com/services/essential-info).
Please find sample redirectmap text file below.
/100001/Product.aspx http://mydomain.com/urlredirect/p100003
/100002/Product.aspx http://mydomain.com/urlredirect/p100005
/Help/Help.aspx?HelpID=6 http://mydomain.com/services/essential-info
/Help/Help.aspx?HelpID=11 http://mydomain.com/services/info-about-delivery-methods
/Magazine/Feature.asp?Id=816 http://mydomain.com/advice/all-about-you.asp
/Magazine/Magazine.aspx?Id=4 http://mydomain.com/advice/beauty
/Advive/all-about-you.asp http://mydomain.com/advice/beauty-in-you
Redirect code written in Apache
RewriteEngine on
RewriteMap text2id txt:/opt/webserver/apache/conf/redirectmap.txt
RewriteRule ^(.*\.(aspx|asp)) ${text2id:$1} [NC,R=301,L]