Solved

Apache URL redirection

Posted on 2011-09-05
13
421 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 77

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 77

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
PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

 

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 77

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 77

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 77

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 77

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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
AIX 5.x set up arrow to recall 11 58
How to move and access a folder outside of the root folder 4 95
unix example issues 18 98
Access_log 17 145
In Solr 4.0 it is possible to atomically (or partially) update individual fields in a document. This article will show the operations possible for atomic updating as well as setting up your Solr instance to be able to perform the actions. One major …
Every server (virtual or physical) needs a console: and the console can be provided through hardware directly connected, software for remote connections, local connections, through a KVM, etc. This document explains the different types of consol…
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 find files with the shell using the find and locate commands. Use locate to find a needle in a haystack.: With locate, check if the file still exists.: Use find to get the actual location of the file.:

792 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