Search code examples
.htaccessdrupal-7symlink

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


Solution

  • 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