Solved

Apache URL redirection

Posted on 2011-09-05
13
424 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
Get 15 Days FREE Full-Featured Trial

Benefit from a mission critical IT monitoring with Monitis Premium or get it FREE for your entry level monitoring needs.
-Over 200,000 users
-More than 300,000 websites monitored
-Used in 197 countries
-Recommended by 98% of users

 

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 500 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

Connect further...control easier

With the ATEN CE624, you can now enjoy a high-quality visual experience powered by HDBaseT technology and the convenience of a single Cat6 cable to transmit uncompressed video with zero latency and multi-streaming for dual-view applications where remote access is required.

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…
Introduction This article is intended for those who are new to PHP error handling (https://www.experts-exchange.com/articles/11769/And-by-the-way-I-am-New-to-PHP.html).  It addresses one of the most common problems that plague beginning PHP develop…
Learn several ways to interact with files and get file information from the bash shell. ls lists the contents of a directory: Using the -a flag displays hidden files: Using the -l flag formats the output in a long list: The file command gives us mor…
Learn how to get help with Linux/Unix bash shell commands. Use help to read help documents for built in bash shell commands.: Use man to interface with the online reference manuals for shell commands.: Use man to search man pages for unknown command…

617 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