LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Server (https://www.linuxquestions.org/questions/linux-server-73/)
-   -   Error while Redirecting page using mod rewrite in apache (https://www.linuxquestions.org/questions/linux-server-73/error-while-redirecting-page-using-mod-rewrite-in-apache-908110/)

jsaravana87 10-14-2011 02:12 AM

Error while Redirecting page using mod rewrite in apache
 
Hi,

i had configured apache and tomcat its started and works well.i had placed index.jsp in apache-tomcat-6.0.26/webapps/ROOT/jsp/wip/index.jsp folder..how can i redirect /jsp/wip/index.jsp to listen to tomcat page using mod rewrite .i had enabled mod_rewrite module in apache http.conf file .i could int able to redirect /jsp/wip/index.jsp to tomcat page automatically http://65.23.87.xx:8080.can someone help me how can enable it

http://65.23.87.xx/jsp/wip/index.jsp to http://65.23.87.xx:8080
vi/etc/httpd/httpd.conf

find:
#LoadModule rewrite_module modules/mod_rewrite.so
LoadModule rewrite_module modules/mod_rewrite.so

Saved the chages changes

service httpd restart

Regards
arun

bathory 10-14-2011 03:18 AM

Hi,

It's better not to use mod_rewrite and use apache as a reverse proxy for tomcat.
For this you'll need mod_proxy_ajp (or mod_jk that is an external apache module)
Check this out that is describing both methods

Regards

jsaravana87 10-16-2011 11:35 PM

Hi

I had enabled the mod rewrite module in httpd.conf

LoadModule rewrite_module modules/mod_rewrite.so

Redirect http://bmw.etl.com/jsp/wip/index.jsp http://bmw.etl.com

but still /jsp/wip/index.jsp never redirecting to bmw.etl.com

im very new to apache can someone help me out what wrong im making in redirecting url

Regards
arun

bathory 10-17-2011 02:26 AM

Hi,

First of all your Redirect is wrong.
2nd, I guess you didn't read my previous post. You need mod_proxy or mod_jk for this, because it's better to hide tomcat running as the backend server.

With mod_rewrite, e.g using:
Code:

RewriteEngine On
RewriteRule jsp/wip/index.jsp http://65.23.87.xx:8080

when someone visits http://bmw.etl.com/jsp/wip/index.jsp he gets redirected externally to http://65.23.87.xx:8080, so he can see that url in the browsers location bar..
With mod_proxy instead, the url is not changing. So better take a look at the link in my previous post and use mod_proxy/mod_proxy_ajp or mod_jk

Regards

jsaravana87 10-18-2011 01:23 AM

Thanks for ur help i got solved

jsaravana87 10-21-2011 01:32 AM

Hi
how can divert tomcat page http://bmw.etl.com:8080/jsp/wip/index.jsp http://bmw.etl.com

but i could in divert tha page http://bmw.etl.com:8080/jsp/wip/index .rewrite rule which i was written was when ever apache page hit / it should want to divert it to tomcat /ROOT/webapps/jsp/b2c/index.jsp

RewriteEngine on
RewriteLogLevel 12
RewriteLog /etc/httpd/logs/rewrite.log
RewriteCond %{HTTP_HOST} ^bmw.etl.com$
RewriteRule http://bmw.etl.com/ http://bmw.etl.com:8080/jsp/b2c/index.jsp

i could int get success then wrote another rule
RewriteRule / http://bmw.etl.com/jsp/b2c/index.jsp

then i tried out something different but it too had a same error
RewriteRule http://bmw.etl.com/ http://bmw.etl.com:8080/jsp/b2c/index.jsp

cd /etc/httpd/conf/httpd.conf
Jkmount / workers1 ...

bathory 10-21-2011 02:26 AM

Hi,

Quote:

RewriteRule http://... http://...
This isn't going to work, because in the RewriteRule you can rewrite a URL (what starts with http://), but a URI (that's a path, like /blah/index.html)
Anyway, I don't fully understand what you want to do, but if you want any request for http://bmw.etl.com to get redirected to tomcat's index.jsp (but not in the fashion of a reverse proxy), then you need this:
Code:

RewriteRule (.*) http://bmw.etl.com:8080/jsp/b2c/index.jsp
If you just want to rewrite /, then you'll need this instead
Code:

RewriteCond %{REQUEST_URI} ^/$
RewriteRule (.*) http://bmw.etl.com:8080/jsp/b2c/index.jsp



All times are GMT -5. The time now is 07:36 AM.