301 Redirect from sub1.mydomain.com to anotherdomain.com/sub1
I have already built a site with a strong page ranking in Google, but I started with too many subdomains, so I've re-worked the code so that it can all be one a single domain.
I have created a separate app which ought to simply act as a filter, permenantly redirecting all requests made to sub1.mydomain.com/something?id=hi
to anotherdomain.com/sub1/something?id=hi
. What's the best way to do this? I've tried writing a servlet but it doesn't like the url-patt开发者_如何学JAVAern /* and I have a feeling this ought to be done as a filter, but I can't get it to work like that either. What's the easiest way to do this in Java?
I just used a simple servlet doing a 301 redirect. To get the correct forwarding url, I ran a regex on the incoming url and altered it as needed.
精彩评论