Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Apache URL redirection

Posted on 2011-09-05
13
Medium Priority
?
428 Views
Last Modified: 2012-05-12
We are using Apache/2.2.3 and need the URL redirection as follows



m.test.com/prodtest/?v=TT78UUU             (User Request)
               |
               |
               |
m.latest.com/test.new/1f_landing/?v=TT78UUU                             (Processed as )
               |
               |
               |
m.test.com/prodtest/?v=TT78UUU           (output domain and url should remain same)

Note : We don't have any prodtest folder
TT78UUU   is a aplha numeric variable

Thanks,
Ramesh
0
Comment
Question by:rameshsukhi123
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 6
  • 6
13 Comments
 
LVL 79

Expert Comment

by:arnold
ID: 36483742
Change alias
Alias /prodtest /some/path/to/directory
to
Alias /prodtest /some/new/path/to/directory

This is part of your configuration file it can be within httpd.conf or an individual file within the conf.d/ /etc/httpd/conf.d /etc/apache2/conf.d.
Depending on the version/distribution of linux you use.
once you make the change, you need to issue a graceful/reload to apache
/etc/init.d/httpd
/etc/init.d/apache
/etc/init.d/apache2
Depending on which is available to you.
0
 

Author Comment

by:rameshsukhi123
ID: 36483925
Hi Arnold,

I'm sorry.

I missed to update that the application is running on Tomcat and Apache is on the front.
So the requests comes to Apache and it forwards it to tomcat.

We are using tomcat6.
0
 
LVL 79

Expert Comment

by:arnold
ID: 36484389
You should then reconfigure tomcat to now use the other directory.
or rename the current directory where tomcat is answering from to the one with the newer data.
A redirect by its nature alters the URL that is displayed in the browser since it is the browser that initiates the connection back using the newly provided URl in the redirect response.
0
Manage your data center from practically anywhere

The KN8164V features HD resolution of 1920 x 1200, FIPS 140-2 with level 1 security standards and virtual media transmissions at twice the speed. Built for reliability, the KN series provides local console and remote over IP access, ensuring 24/7 availability to all servers.

 

Author Comment

by:rameshsukhi123
ID: 36484471
I'm trying the below config :

RewriteEngine On
RewriteCond %{REQUEST_FILENAME}   !-s
RewriteRule prodtest test.new/1f_landing/?v=$1  [R,NC,L]

It works but when i hit

http://m.test.com/prodtest/1f_landing/?v=TT78UUU
                          |
                          |
http://m.test.com/test.new/1f_landing/?v=

but i want

m.test.com/prodtest/?v=TT78UUU


Please help me to fix this .
                             
0
 
LVL 79

Assisted Solution

by:arnold
arnold earned 2000 total points
ID: 36484541
Once you rewrite the URL it is sent to the browser saying, you wanted X, but it has moved to y.
The browser then initiates a new request for Y.

To do what you ask, you have to make changes on your tomcat server to serve the data from test.new when the request comes from /prodtest/.

You should not be latering any configuration on the apache side, but you should adjust the parameters on the tomcat side.


 
0
 

Author Comment

by:rameshsukhi123
ID: 36484685
how to do that on tomcat side ?
0
 
LVL 79

Expert Comment

by:arnold
ID: 36484723
Look at the  configuration.

copy the old stuff so you have a backup.
Copy the new stuff in place of the old stuff.

Look at how your /etc/httpd/conf.d/tomcat.conf

Look at how where and how your existing /prodtest is defined within the apache configuation.




0
 

Accepted Solution

by:
rameshsukhi123 earned 0 total points
ID: 36485071
This is my apache virtual conf file :

<VirtualHost dev02:80>
   ServerName a.test.com
   ServerAlias m.test.com
   ErrorLog /var/log/httpd/a.error.log
   CustomLog /var/log/httpd/a.log combined

   SetEnv force-proxy-request-1.0 1
   SetEnv proxy-nokeepalive 1


        RewriteEngine On
        RewriteLog /var/log/httpd/rewrite.log
        RewriteLogLevel 9

        RewriteCond %{REQUEST_FILENAME}   !-s
        RewriteRule prodtest/1f_landing/ test.new/1f_landing/$1 [R,NC,L]

   ProxyRequests Off
   ProxyPreserveHost On

   <Proxy *>
     AddDefaultCharset Off
     Order deny,allow
     Allow from all
   </Proxy>

   ProxyPass / http://test02:8086/
   ProxyPassReverse / http://test02:8086/
</VirtualHost>

And now when i'm hitting

http://m.test.com/prodtest/1f_landing/?v=TT78UUU

i'm geting

http://m.test.com/test.new/1f_landing/?v=TT78UUU

I just want to replace test.new with prodtest.
0
 
LVL 79

Expert Comment

by:arnold
ID: 36485249
Proxy pass is what passes the query to tomcat.
Your apache cofiguration suggest that it is setup as a reverse proxy to the tomcat.

rename the prodtest to prodtest.old and test.new to prodtest.


Look at the configuration of your tomcat/catalina.conf or something like that.
0
 

Assisted Solution

by:rameshsukhi123
rameshsukhi123 earned 0 total points
ID: 36519543
I've requested that this question be closed as follows:

Accepted answer: 0 points for rameshsukhi123's comment http:/Q_27291618.html#36485071
Assisted answer: 0 points for rameshsukhi123's comment http:/Q_27291618.html#36484471
Assisted answer: 500 points for arnold's comment http:/Q_27291618.html#36484541

for the following reason:

It got fixed by creating a symbolic link (prodtest) to the app directory .
0
 

Author Comment

by:rameshsukhi123
ID: 36519544
Please give 300 points to my answer , as while closing the question i didn't got any option for that , because of this it got closed like this.
0
 
LVL 79

Expert Comment

by:arnold
ID: 36519943
You should request attention for the question to have the assignment adjusted.  You can not award yourself points. You would be able to award what you view my comments are worth.
i.e. if you figured out the solution on your own, you can add what/how you came to the solution and select that post as the solution 0 points.
If other comments were helpful, you can still select your question as the answer with the others as assisting and assign the point value you think is appropriate.
0
 

Expert Comment

by:JustAMod
ID: 36533864
Thread reopened to allow a proper closure, based on posted solution.

JustAMod
CS Moderator
0

Featured Post

Flexible connectivity for any environment

The KE6900 series can extend and deploy computers with high definition displays across multiple stations in a variety of applications that suit any environment. Expand computer use to stations across multiple rooms with dynamic access.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Installing FreeBSD… FreeBSD is a darling of an operating system. The stability and usability make it a clear choice for servers and desktops (for the cunning). Savvy?  The Ports collection makes available every popular FOSS application and packag…
I have been running these systems for a few years now and I am just very happy with them.   I just wanted to share the manual that I have created for upgrades and other things.  Oooh yes! FreeBSD makes me happy (as a server), no maintenance and I al…
This video shows how to set up a shell script to accept a positional parameter when called, pass that to a SQL script, accept the output from the statement back and then manipulate it in the Shell.
In a previous video, we went over how to export a DynamoDB table into Amazon S3.  In this video, we show how to load the export from S3 into a DynamoDB table.
Suggested Courses

722 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question