Page 1 of 1

Read file in another domain folder

Posted: Thu Jul 03, 2014 6:57 pm
by lapsrj
Hi,

I don't have much experience in servers and I'm trying to do something but I don't know how to do it and do it in a safe way. What I want is:

I have a server with vestacp and configured two domains: domain1.tld and domain2.tld. When someone access domain1.tld I want the server to read the file in domain2.tld/folder. I tried to do it with a .htaccess file but I get a 400 Bad Request error.

The htaccess file that I used was:

Code: Select all

Options +FollowSymLinks -MultiViews
RewriteEngine On

RewriteRule ^(.*) ../../domain2.tld/public_html/folder/$1
Is the .htaacess right? Maybe I will need to change some folder permissions? If so, will it be safe? Can somebody help me? Thanks.

Re: Read file in another domain folder

Posted: Thu Jul 03, 2014 7:21 pm
by imperio
Hi, lapsrj
you can change DocumentRoot direcrory for domain1.tld in httpd config of your domains
What operating system on your server?

Re: Read file in another domain folder

Posted: Thu Jul 03, 2014 7:37 pm
by lapsrj
Thanks for your answer, imperio! My server runs Ubuntu.

The problem with changing the DocumentRoot is that I will need to pass a parameter in the url. The parameter is the domain without the tld. The way I thought was: I have the files in domain1.tld/folder. Someone access domain2.tld, the server will read the file in domain1.tld/folder but will add a parameter so the file can know the domain and read the appropriate info.

However I could try put a htaccess in domain1.tld/folder to get the domain and pass as a parameter.

How can I change the DocumentRoot directory? I will test this way.

Re: Read file in another domain folder

Posted: Thu Jul 03, 2014 7:53 pm
by imperio
/home/$user/conf/web/apache2.conf
in apache2.conf find virtualhost with your domain domain1.tld
find this code

Code: Select all

DocumentRoot /home/$user/web/domain1.tld/public_html
add this

Code: Select all

DocumentRoot /home/$user/web/domain2.tld/public_html
$user - name of your user
domain2.tld - your real domain
also you can change folder public_html

Code: Select all

service apache2 restart

Re: Read file in another domain folder

Posted: Thu Jul 03, 2014 7:55 pm
by lapsrj
Thanks! I will try it.