electrophanteau
electrophanteau

Reputation: 1332

redirect /subdirectory to /symlink/subdirectory where /symlink points to /

i'm working on a drupal7 multisite setup based on subdirectories where example.com is used for the main website and example.com/subsite is another standalone drupal install. subsite is a symlink located in the root directory and also pointing to the root directory to give the subsite access to drupal core files.

now i have to make static content available via example.com/subsite/static, so i created a directory static in the root directory. that all works fine.

the problem is, that example.com/static is now also accessable and i want to prevent that.

i tried to redirect all requests to /static to /subsite/static resulting in inconsistent behaviour and redirect loops.

directory structure:

/
/{various drupal directories}
/subsite -> /
/static

rewrite rule:

RewriteRule ^/static/(.*)$ /subsite/static/$1 [R,L]

thx in advance

Upvotes: 2

Views: 447

Answers (2)

electrophanteau
electrophanteau

Reputation: 1332

i fixed the redirect loops by using a rewrite condition, should have thought of that before.

RewriteCond %{REQUEST_URI} !^/subsite/(.*)$
RewriteRule ^static/(.*)$ /subsite/static/$1 [L,R=301]

thx anyway @florian-lemaitre for trying to help me

Upvotes: 1

Florian Lemaitre
Florian Lemaitre

Reputation: 5748

Is this what you want?

RewriteBase /    
RewriteRule ^static/(.*)$ /subsite/static/$1 [L,R=301]
RewriteRule ^subsite/static/(.*)$ /static/$1 [L]
  • In the first line we redirect all call to /static/ to /subsite/static/.
  • In the second line we rewrite all call to /subsite/static/ to /static.

If it doesn't work please post your whole .htaccess file.

Upvotes: 1

Related Questions