Solved

How can I redirect one URL to another (including subdirectories) without changing the URL in address bar (so something like mod_rewrite features)?

Posted on 2004-08-12
4
1,013 Views
Last Modified: 2010-03-04
In a mod_rewrite, if the rewriterule result contains an external URL such as http://www.example.com/$1 then it actually redirects instead of rewriting, because the result URL must be internal for it to work normally.

What I want is basically explained in my topic - How can I redirect one URL to another (including subdirectories) without changing the URL in address bar (so something like mod_rewrite features)?

I heard about using ProxyPass but am afraid of how to use it, implement it, etc.

So any suggestions that might help?

If it helps, then this is what I have right now in my mod_rewrite (and it achieves exactly what I want, except that it redirects and does not keep the original URL in address bar.)

.HTACCESS CONTENT (in http://blog.kinggary.com/ ):
RewriteRule ^(.*)$ http://gary.blogs.com/$1
0
Comment
Question by:Chopianissima
  • 2
4 Comments
 
LVL 51

Expert Comment

by:ahoffmann
ID: 11791629
you cannot redirect without hanging URL in addressbar (except using malware on the client: JavaScript, ActiveX etc.)

If you just need to rewrite, then you could use RewriteRule with [P] flag
0
 
LVL 15

Accepted Solution

by:
samri earned 500 total points
ID: 11794301
I would suggest for you to explore using ProxyPass (or reverse proxy concept).  This approach would bring the remote webserer namespace into yours.

Take a look at apache mod_proxy module (http://httpd.apache.org/docs-2.0/mod/mod_proxy.html).

Specific to your requirement, I would personnally go for using proxy.  Just jump to a example on Apache website :
http://httpd.apache.org/docs-2.0/mod/mod_proxy.html#examples

You could include this in the Vhost for bloggs.kinggary.com (a suggestion).
--
ProxyRequests On
ProxyVia On

<Proxy *>
  Order deny,allow
  Deny from all
  Allow from internal.example.com
</Proxy>

Reverse Proxy
ProxyRequests Off

<Proxy *>
  Order deny,allow
  Allow from all
</Proxy>

ProxyPass             /   http://gary.blogs.com/
ProxyPassReverse  /   http://gary.blogs.com/
0
 

Author Comment

by:Chopianissima
ID: 11795477
Please keep in mind I'm still on Apache 1.3.31.

Also, mod_proxy module does not load with my Apache; what do I need to put in to make it load with Apache? I tried putting in the line to load the .so and the .c for mod_proxy but I just get an error saying there is an error with the httpd.conf (so I just revert my changes.)
0
 
LVL 15

Expert Comment

by:samri
ID: 11798996
hi Chopianissima,

Not a problem, Apache 1.3.x have a corresponding proxy module as well.  Check you modules directory for mod_proxy.so (which I think). (http://httpd.apache.org/docs/mod/mod_proxy.html).  Take a look at forward/reverse proxy section (http://httpd.apache.org/docs/mod/mod_proxy.html#forwardreverse).

Just load the proxy module, and


#  ProxyRequests On
  ProxyRequests Off
  <Proxy *>
    Order deny,allow
    Deny from all
    Allow from 127.0.0.1 192.168
 </Proxy>

ProxyPass /stokely http://www.stokely.com/
ProxyPassReverse /stokely http://www.stokely.com/

ProxyPass /eskimo http://www.eskimo.com/
ProxyPassReverse /eskimo http://www.eskimo.com/
0

Featured Post

Enterprise Mobility and BYOD For Dummies

Like “For Dummies” books, you can read this in whatever order you choose and learn about mobility and BYOD; and how to put a competitive mobile infrastructure in place. Developed for SMBs and large enterprises alike, you will find helpful use cases, planning, and implementation.

Question has a verified solution.

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

Suggested Solutions

Introduction As you’re probably aware the HTTP protocol offers basic / weak authentication, which in combination with the relevant configuration on your web server, provides the ability to password protect all or part of your host.  If you were not…
If your site has a few sections that need to be secure when data is transmitted between the server and local computer, such as a /order/ section for ordering or /customer/ which contains customer data, etc it would of course be recommended to secure…

749 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