Solved

Apache URL redirection

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

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

 
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

Control application downtime with dependency maps

Visualize the interdependencies between application components better with Applications Manager's automated application discovery and dependency mapping feature. Resolve performance issues faster by quickly isolating problematic components.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
SSH commands for Nas4free 21 370
How to Change Interface on Cisco IOU 11 83
Change local server setting in php 6 81
Unix/bash: scripted arithmetic 13 92
If you are running a LAMP infrastructure, this little code snippet is very helpful if you are serving lots of HTML, JavaScript and CSS-related information. The mod_deflate module, which is part of the Apache 2.2 application, provides the DEFLATE…
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…
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…
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.

947 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

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now