redirect using mod_rewrite

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?
dalelumAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

samriCommented:
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

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
JOligarioCommented:
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
BigRatCommented:
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
Cloud Class® Course: SQL Server Core 2016

This course will introduce you to SQL Server Core 2016, as well as teach you about SSMS, data tools, installation, server configuration, using Management Studio, and writing and executing queries.

samriCommented:
any luck on this?
0
CaiapfasCommented:
I would use a 301 redirect in the .htaccess file for that diorectory
0
VenabiliCommented:
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
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Apache Web Server

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.