simple redirect?

6 posts / 0 new
Last post
#1 Wed, 07/23/2008 - 02:25
bdemeester

simple redirect?

Hello,

I want to setup the following. Every request towards http://www.mydomain.com/google should be redirected towards http://www.google.com. Google is just an example taken to show the principle.

In virtualmin I did the following : Configure Websites -> Aliases and Redirects Map local to remote URLs Local URL path : /google/ Remote URL : http://www.google.be/

Map remote Location: headers to local Local URL path : /google/ Remote URL : http://www.google.be/

Seems very simple..... But I always receive the following message when browing to http://www.mydomain.com/google/ : Forbidden You don't have permission to access /google/ on this server.

Any idea how I can fix this permission issue?

It's a fresh install of Virtualmin Pro on Debian 4.0

Thanks!

Bart

Wed, 07/23/2008 - 03:51
ronald
ronald's picture

so the most simple thing I do is to have a index.php in that folder and put this code in it:

[code:1]
<?php
header("Location: http://google.be/"«»); /* Send browser to www.site.tld */
exit; /* Make sure all following code does not execute */
?>
[/code:1]

you can try :
Map local to remote URLs
Local URL path : /full/path/to/google/

I don't think you need this at all:
Map remote Location: headers to local
Local URL path : /google/
Remote URL : http://www.google.be/

Wed, 07/23/2008 - 05:36 (Reply to #2)
bdemeester

Ronald,

I agree that your proposed solution should work. I cannot test it at the moment from where I am located now.

There must however be a way to do the same using the apache config.... That is what rewriting an reverse proxying is meant for, no ?

Somebody has any ideas how?

Thanks!

BArt

Wed, 07/23/2008 - 08:28 (Reply to #3)
ronald
ronald's picture

using that piece of code will work and it's serverside, thus fast.
also look below the code i wrote

<div class='quote'>you can try :
Map local to remote URLs
Local URL path : /full/path/to/google/

I don't think you need this at all:
Map remote Location: headers to local
Local URL path : /google/
Remote URL : http://www.google.be/</div>

Thu, 07/24/2008 - 09:44 (Reply to #4)
bdemeester

I tried this :
[code:1]&lt;?php
header(&quot;Location: http://google.be/&quot;&Acirc;&laquo;&Acirc;&raquo;);
exit;
?&gt; [/code:1]

And it works fine. The browser is redirected to the google site.

However, let's complicate things now.
Imagine that I have a website running on an internal server 192.168.1.100.
I want to redirect everything drom http://www.mydomain.com/internal to this internal server

I cannot use above php-script as the internal server is ofc not reachable from the internet and not known by internet DNS servers.
That's where I need reverse proxying.

In virtualmin I configured this in &quot;Server Configuration -&gt; Proxy Paths&quot;
URL path = /internal/
Destination URLs = http://192.168.1.100/

I see that in the apache config of my domain following is added :
[code:1]ProxyPass /internal/ http://192.168.1.100
ProxyPassReverse /internal/ http://192.168.1.100
&lt;Proxy *&gt;
allow from all
&lt;/Proxy&gt;[/code:1]

This still results in the following error code in my browser when pointing to http://www.mydomain.com/internal/:

<div class='quote'>403 - Forbidden
You don't have permission to access /oxee/ on this server.
</div>

Any idea what I am doing wrong here?

Thanks for the support!

Bart

Thu, 07/24/2008 - 10:26 (Reply to #5)
bdemeester

Found it!

Enabling the proxy_hhtp module did the trick!

[code:1]a2enmod proxy_http[/code:1]

Topic locked