Forum Moderators: phranque

Message Too Old, No Replies

Apache redirect based on url you are coming from

         

jovian

10:20 pm on Nov 16, 2005 (gmt 0)



I am trying to do the following. Based on a request coming in, if the request page is not there (error 404), pass the user on to a jsp page error.jsp. This jsp page checks and redirects based on the original client url. So, if the client comes from url /test.jsp redirect the client to /test2.jsp. And if the client comes from /test.jsp redirect them to /test3.jsp. How can I achieve this using Apache .htaccess and/or httpd.conf?

jdMorgan

11:05 pm on Nov 16, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



jovian,

Welcome to WebmasterWorld!

You can use mod_rewrite's RewriteCond directive checking %{REQUEST_FILENAME} for file-exists (see -f flag), and then *internally rewrite* to the jsp script if the test fails. Your implementation should not redirect or return a 404 response until your are sure that there is no content associated with the requested URL.

For more information, see the documents cited in our forum charter [webmasterworld.com] and the tutorials in the Apache forum section of the WebmasterWorld library [webmasterworld.com].

Jim