Forum Moderators: phranque
How can a subdomain load the javascript file using a relative path to avoid doing Ajax calls on a cross domain?
Is it possible to do an Internal Rewrite in Apache .htaccess file like below?
RewriteRule ^base/(.+)?$ /path_to_root/$1 [L]
where the short url "/base/test.js" is handled by the Rewrite Rule above
Thank you for your help in advance
If your subdomains are all mapped to the same DocumentRoot as your main domain, and you then use a rewriterule to 'map' the subdomain requests into subfolders as separate filespace as needed, then this approach will work.
However, if the subdomains have separate DocumentRoots --either completely-separate or in subdirectories below your main domain's DocumentRoot-- then it won't be possible to take an incoming HTTP request and rewrite it "up" in the directory-space (This can't be allowed because it would be a huge security risk if the domains/subdomains were separately owned or controlled).
So in this case, you'll need to look into using mod_alias Alias or AliasMatch directives to re-map the requests from the server config level, or alternatively, to create symlinks in each of the subdomains to point test.js requests arriving for that subdomain over to some common filespace containing the 'real' file. With the right file permissions settings, this should be possible.
Jim