Solved

Apache URL redirection

Posted on 2011-09-05
13
422 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
  • 6
  • 6
13 Comments
 
LVL 78

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 78

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
Simplifying Server Workload Migrations

This use case outlines the migration challenges that organizations face and how the Acronis AnyData Engine supports physical-to-physical (P2P), physical-to-virtual (P2V), virtual to physical (V2P), and cross-virtual (V2V) migration scenarios to address these challenges.

 

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 78

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 78

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 78

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 78

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

Portable, direct connect server access

The ATEN CV211 connects a laptop directly to any server allowing you instant access to perform data maintenance and local operations, for quick troubleshooting, updating, service and repair.

Question has a verified solution.

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

Using libpcap/Jpcap to capture and send packets on Solaris version (10/11) Library used: 1.      Libpcap (http://www.tcpdump.org) Version 1.2 2.      Jpcap(http://netresearch.ics.uci.edu/kfujii/Jpcap/doc/index.html) Version 0.6 Prerequisite: 1.      GCC …
FreeBSD on EC2 FreeBSD (https://www.freebsd.org) is a robust Unix-like operating system that has been around for many years. FreeBSD is available on Amazon EC2 through Amazon Machine Images (AMIs) provided by FreeBSD developer and security office…
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…
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.

713 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