LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Server
User Name
Password
Linux - Server This forum is for the discussion of Linux Software used in a server related context.

Notices


Reply
  Search this Thread
Old 10-14-2011, 02:12 AM   #1
jsaravana87
Member
 
Registered: Aug 2011
Location: Chennai,India
Distribution: Redhat,Centos,Ubuntu,Dedian
Posts: 558
Blog Entries: 5

Rep: Reputation: Disabled
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

Last edited by jsaravana87; 10-14-2011 at 02:31 AM.
 
Old 10-14-2011, 03:18 AM   #2
bathory
LQ Guru
 
Registered: Jun 2004
Location: Piraeus
Distribution: Slackware
Posts: 13,165
Blog Entries: 1

Rep: Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032
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
 
Old 10-16-2011, 11:35 PM   #3
jsaravana87
Member
 
Registered: Aug 2011
Location: Chennai,India
Distribution: Redhat,Centos,Ubuntu,Dedian
Posts: 558

Original Poster
Blog Entries: 5

Rep: Reputation: Disabled
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

Last edited by jsaravana87; 10-17-2011 at 12:17 AM.
 
Old 10-17-2011, 02:26 AM   #4
bathory
LQ Guru
 
Registered: Jun 2004
Location: Piraeus
Distribution: Slackware
Posts: 13,165
Blog Entries: 1

Rep: Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032
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
 
Old 10-18-2011, 01:23 AM   #5
jsaravana87
Member
 
Registered: Aug 2011
Location: Chennai,India
Distribution: Redhat,Centos,Ubuntu,Dedian
Posts: 558

Original Poster
Blog Entries: 5

Rep: Reputation: Disabled
Thanks for ur help i got solved
 
Old 10-21-2011, 01:32 AM   #6
jsaravana87
Member
 
Registered: Aug 2011
Location: Chennai,India
Distribution: Redhat,Centos,Ubuntu,Dedian
Posts: 558

Original Poster
Blog Entries: 5

Rep: Reputation: Disabled
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 ...

Last edited by jsaravana87; 10-21-2011 at 02:07 AM.
 
Old 10-21-2011, 02:26 AM   #7
bathory
LQ Guru
 
Registered: Jun 2004
Location: Piraeus
Distribution: Slackware
Posts: 13,165
Blog Entries: 1

Rep: Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032
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

Last edited by bathory; 10-21-2011 at 01:22 PM. Reason: wrong url
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Apache mod-rewrite help / question sir-lancealot Linux - Server 2 02-11-2010 09:35 AM
[SOLVED] Apache MOD REWRITE yoachan Linux - Server 4 01-21-2010 01:15 AM
Apache Mod Rewrite Help vital_101 Linux - Server 4 12-02-2009 12:38 AM
Mod Rewrite - Apache FormalLogic Linux - Server 2 03-19-2008 01:30 AM
apache mod rewrite Robert0380 Linux - Software 5 07-31-2003 04:42 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Server

All times are GMT -5. The time now is 04:08 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration