Forum Moderators: open
They're running Apache with Tomcat on a Win NT4 server. They have an incredible tangle of redirects and map rules that come out of a file called "shortcuts.jsp" and they want to make some more.
I can already see some total nuttiness with their URLs on search engines, but I'm not sure where it all comes from -- I know absolutely ZERO about java.
So how does a jsp redirect affect search engines? Is this a "safe" way to create redirects as far as search engines are concerned?
The first one, using the servlet method sendRedirect() passes a 302 back to the browser.
The second, and the more likely in this case, is the jsp:forward directive - which calls the servlet pageContext.forward() method. This all happens server side, so the target file specified in the forward method is served back to the client without any extra requests being made. The original URL will still be displayed in the browser address bar.
In this case, I would assume that a search engine would be ok with this since it will index the target file rather than the redirecting one. But I'm guessing based on how these methods work. I've never used a set up like that.
Why all the redirects?
Why all the redirects
Sometimes to set up a shorter, type-in URL for print. Sometimes just being much to casual with the URL name space. But basically, too many cooks in the kitchen and no head chef. And they main dish they prepared was spaghetti.
Some of the SE problems I see occur with subdomains. As you described, the URL in the location bar does not change. Then the next link from the new destination page is a relative link, and the original subdomain remains in the URL.
All this would be fine EXCEPT that the server has been misconfigured for months and the subdomains are all crossed up with each other. So now the search engine listings use sub1.example.com to point to the content of sub2.example.com -- and there are some very bizarre combinations of content and url.
Can we create 301 redirects in this scenario to sort things out?
<%
response.setHeader("SC_MOVED_PERMANENTLY", "http://www.example.com/newfile.htm");
%>
I tried this though, and the browser didn't follow the redirect.
<%
response.setStatus(HttpServletResponse.SC_MOVED_PERMANENTLY);
response.setHeader("Location", "http://www.example.com/newfile.htm");
%>
This one works ok, it sends the 301 status code and the browser follows the redirect, but the URL in the address bar is still the original request, so I suspect you may still have the same problem with relative paths.
In both cases, SC_MOVED_PERMANENTLY is defined in the HttpServletResponse class as a static integer, 301.
There's more info on the HttpServletResponse object here: [java.sun.com ]
Sorry I can't be of more help.