Vesta Control Panel - Forum

Community Forum

Skip to content

Advanced search
  • Quick links
    • Main site
    • Github repo
    • Google Search
  • FAQ
  • Login
  • Register
  • Board index Main Section Web Server
  • Search

Read file in another domain folder

Questions regarding the Web Server
Apache + Nginx, Nginx + PHP5-FPM
Post Reply
  • Print view
Advanced search
5 posts • Page 1 of 1
lapsrj
Posts: 3
Joined: Thu Jul 03, 2014 6:44 pm

Read file in another domain folder
  • Quote

Post by lapsrj » Thu Jul 03, 2014 6:57 pm

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.
Top

imperio
VestaCP Team
Posts: 7000
Joined: Sat Dec 01, 2012 12:37 pm
Contact:
Contact imperio
Website

Re: Read file in another domain folder
  • Quote

Post by imperio » Thu Jul 03, 2014 7:21 pm

Hi, lapsrj
you can change DocumentRoot direcrory for domain1.tld in httpd config of your domains
What operating system on your server?
Top

lapsrj
Posts: 3
Joined: Thu Jul 03, 2014 6:44 pm

Re: Read file in another domain folder
  • Quote

Post by lapsrj » Thu Jul 03, 2014 7:37 pm

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.
Top

imperio
VestaCP Team
Posts: 7000
Joined: Sat Dec 01, 2012 12:37 pm
Contact:
Contact imperio
Website

Re: Read file in another domain folder
  • Quote

Post by imperio » Thu Jul 03, 2014 7:53 pm

/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
Top

lapsrj
Posts: 3
Joined: Thu Jul 03, 2014 6:44 pm

Re: Read file in another domain folder
  • Quote

Post by lapsrj » Thu Jul 03, 2014 7:55 pm

Thanks! I will try it.
Top


Post Reply
  • Print view

5 posts • Page 1 of 1

Return to “Web Server”



  • Board index
  • All times are UTC
  • Delete all board cookies
  • The team
Powered by phpBB® Forum Software © phpBB Limited
*Original Author: Brad Veryard
*Updated to 3.2 by MannixMD
 

 

Login  •  Register

I forgot my password