views:

23

answers:

1
+1  Q: 

url redirection

Hi,

I need some help with regards to the url redirection. Here is the problem.

We have a website with a section as http://www.site.com/sectionxxx/index.jsp

we have another domain http://www.sectionxxx.com.

The task is to forward any request comming for the http://www.sectionxxx.com; direct to http://www.site.com/sectionxxx/index.jsp.

Any idea?

P

+1  A: 

in .htaccess file on server

Redirect permanent http://www.sectionxxx.com/index.jsp http://www.site.com/sectionxxx/index.jsp.

or you can create page http://www.sectionxxx.com/index.jsp page and add

<% 
    String redirectURL = "http://www.site.com/sectionxxx/index.jsp"; 
    response.sendRedirect(redirectURL);
%> 

or you can write on the same page

<jsp: forward page="http://www.site.com/sectionxxx/index.jsp"/&gt;

this will forward page...

Nitz
The `.htaccess` file will only work if your servletcontainer is fronted by Apache HTTPD (since `.htaccess` files are Apache HTTPD specific, won't work on Tomcat and so on). The scriptlet way will work, but a `Filter` like [this one](http://tuckey.org/urlrewrite/) is the preferred way. The `jsp:forward` is entirely server-side and will not reflect the URL change in browser address bar.
BalusC