LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Server (https://www.linuxquestions.org/questions/linux-server-73/)
-   -   Redirection with different folders (https://www.linuxquestions.org/questions/linux-server-73/redirection-with-different-folders-842786/)

hugohome 11-06-2010 06:00 PM

Redirection with different folders
 
Hi everybody!

I have a problem about redirection over Apache2 over Debian Lenny. We have build a LAMP, and our programmer make a software with these features:

When you put on your browser (i.e.) http://hugohome.org/inside, you access to the program in /var/www/vhosts/hugohome/inside. And when you put http://hugohome.org/outside you access to the program in /var/www/vhosts/hugohome/outside. Today, if you just put http://hugohome.org our Apache answers 403 (forbidden), because we had blocked folder access. (You know....isn't the right way). Our Apache's Document Root is in /var/www/vhosts/hugohome.

Our goal is to change definitely http://hugohome.org to access -> /var/www/vhosts/hugohome/inside. This is our main intention. Also, we can continue with http://hugohome.org/outside pointing to /var/www/vhosts/hugohome/outside. I thought, hmm easy!: I can change the DocumentRoot to /var/www/vhosts/hugohome/inside and try with an Alias to outside. But the problem is that the programmer has taken the software reference with /var/www/vhosts/hugohome and when I tried to change the Document Root the programas didn't work fine (loops, error 404, etc).

¿How can I do?. I have tried with Apache with many manners, but I just have a relative success with:
"RedirectMatch ^/$ http://hugohome.org/inside/". It works, but the Browser shows the ugly http://hugohome.org/inside. Our intention is just show http://hugohome.org. Unfortunately we can't work directly with the DNS servers, and I guess that I can resolve with (i.e.) Apache and Bind together.

¿Any ideas?. Any help will be truly appreciated!!

Have a beautiful weekend!

Hugohome

bathory 11-07-2010 03:36 AM

Hi,

You can use mod_rewrite. Create a .htaccess file in your DocumentRoot (/var/www/vhosts/hugohome) containing:
Code:

RewriteEngine on

RewriteCond %{REQUEST_URI} ^/$
RewriteRule (.*) /inside/ [L]

Regards

hugohome 11-09-2010 09:20 AM

Thanks Bathory, and my apologize because of my delaying answer. I tried with your tip, but the browser countinues putting "http://www.hugohome.org/inside". Unfortunately the programmer guy and I didn't have more time to testing, because our customer want to kill us. So, we modify the software structure and move the /inside content into the Document Root. At the end, It works with this manner:

At Root --> http://www.hugohome.org (with the former folder "inside" moved at root).

Queries http://www.hugohome.org/outside pointing to the folder "outside". Quite silly solution, but we didn't have more time.

We will try with our local server, to get a final solution. Sooner or later will be cross to the same trouble. When I have a answer, I will put here.

Thanks again and best regards,

Hugohome

bathory 11-09-2010 04:07 PM

Hi,

It should work.
Maybe apache does not look for .htaccess files. To enable this you need to have:
Code:

AllowOverride All
in the <Directory /var/www/vhosts/hugohome>...</Directory> section of /httpd.conf.

Regards


All times are GMT -5. The time now is 09:34 PM.