?
Solved

redirect using mod_rewrite

Posted on 2003-03-05
9
Medium Priority
?
218 Views
Last Modified: 2011-10-03
I have two domains hosted from the same server. I'm trying to use mod_rewrite to send requests for www.foo.com to www.bar.com, but i want to maintain www.foo.com in the browser's address field.

So far, I can do the redirect, but I haven't figured out how to retain the original url in the browser. Ideas?
0
Comment
Question by:dalelum
[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
9 Comments
 
LVL 15

Accepted Solution

by:
samri earned 200 total points
ID: 8077811
dalelum,

To my knowledge, mod_rewrite will change the location url (in the location bar) as well.  If you plan to have the request to be forwarded to a remote server while maintaining the namespace to your web server, I would believe that you could you mod_proxy for that.

http://httpd.apache.org/docs/mod/mod_proxy.html

http://httpd.apache.org/docs/mod/mod_proxy.html#proxypass
http://httpd.apache.org/docs/mod/mod_proxy.html#proxypassreverse

Or maybe you could use proxy pass-through feature [P],

http://httpd.apache.org/docs/mod/mod_rewrite.html#RewriteRule

---excerpt from Apache website documentation.

'proxy|P' (force proxy)
This flag forces the substitution part to be internally forced as a proxy request and immediately (i.e., rewriting rule processing stops here) put through the proxy module. You have to make sure that the substitution string is a valid URI (e.g., typically starting with http://hostname) which can be handled by the Apache proxy module. If not you get an error from the proxy module. Use this flag to achieve a more powerful implementation of the ProxyPass directive, to map some remote stuff into the namespace of the local server.
Notice: To use this functionality make sure you have the proxy module compiled into your Apache server program. If you don't know please check whether mod_proxy.c is part of the ``httpd -l'' output. If yes, this functionality is available to mod_rewrite. If not, then you first have to rebuild the ``httpd'' program with mod_proxy enabled.
---
0
 
LVL 1

Expert Comment

by:JOligario
ID: 8081402
why not use a simple frame?

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<HTML>
<HEAD>
     <META http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
     <TITLE>foo.com.com</TITLE>
</HEAD>
<FRAMESET rows="100%,*" border=0 frameborder=0 framespacing=0>
     <FRAME name=top src="http://bar.com" noresize>
</FRAMESET>
</HTML>
0
 
LVL 27

Expert Comment

by:BigRat
ID: 8081467
I would have though that mod-rewrite to simply rewrite the url depending on the host would work. See the rewrite example Virtual User Hosts at http://httpd.apache.org/docs/misc/rewriteguide.html

Note that the example does not do a redirect! ([R] option)

HTH

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

 
LVL 15

Expert Comment

by:samri
ID: 8933629
any luck on this?
0
 
LVL 2

Expert Comment

by:Caiapfas
ID: 11721596
I would use a 301 redirect in the .htaccess file for that diorectory
0
 
LVL 20

Expert Comment

by:Venabili
ID: 11782507
Caiapfas ,

This question is older than a year...The Asker is obviously not around that's why we should close it... Adding any comments cannot bring you any points...
0

Featured Post

Complete VMware vSphere® ESX(i) & Hyper-V Backup

Capture your entire system, including the host, with patented disk imaging integrated with VMware VADP / Microsoft VSS and RCT. RTOs is as low as 15 seconds with Acronis Active Restore™. You can enjoy unlimited P2V/V2V migrations from any source (even from a different hypervisor)

Question has a verified solution.

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

As Wikipedia explains 'robots.txt' as -- the robot exclusion standard, also known as the Robots Exclusion Protocol or robots.txt protocol, is a convention to prevent cooperating web spiders and other web robots from accessing all or part of a websit…
Over the last year I have answered a couple of basic URL rewriting questions several times so I thought I might as well have a stab at: explaining the basics, providing a few useful links and consolidating some of the most common queries into a sing…
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…
Suggested Courses
Course of the Month8 days, 8 hours left to enroll

764 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