Andrei Herford
Andrei Herford

Reputation: 18729

Howto use path/directory outside the domain root via symlink without access to domain config?

I am working an a shared hosting plattform which does not allow to edit or access the Apache config file.

The goal is to access the same files from two different domains which point to different domain roots:

test.example.com     --->   /test_root/web
public.example.com   --->   /public_root/web

Now I would like to access the same files using test.example.com/some/files/... and public.example.com/some/files/...

Of course I could simply copy the files to /test_root/web/some/files/... and to /public_root/web/some/files/... but this obviously just an example. In reality the files are a helpdesk system which should be integreated both into the test- and public-site. Copying the files would include maintaining two different systems, etc.

The goal is, to place the the files somewhere outside the two domain roots and make them available from both domains:

/test_root/web/some/files     --->   /path/to/some/files
/public_root/web/some/files   --->   /path/to/some/files

I created symlink to achive this (ln -s ...) but this does not work out. When I access on of the domains (e.g. test.example.com/some/files) I only get a blank page without any information what whent wrong.

I assume that the Apache is not configured to follow the symlinks. Without access to the Apache config I can neither check nor fix it.

Adding Symlinks to .../web/.htacess does not make any difference:

// test_root/web/.htaccess
Options +FollowSymLinks

So the question is: How can I make files outside the domain root available within a domain? Is this even possible? Is this possible using symlinks?

Upvotes: 0

Views: 492

Answers (1)

Diogo Jesus
Diogo Jesus

Reputation: 318

Add this in you .htaccess file.

RewriteEngine on
RewriteBase /
RewriteCond %{HTTP_HOST} test.example.com/path/to/files [NC]
RewriteRule ^(.*)$ http://public.example.com/path/to/files [R=301,NC]

Test out this code. /path/to/files must be under /public_root/web/.
Something like /public_root/web/path/to/files/

Upvotes: 1

Related Questions