niklas niklas - 3 months ago 11
Apache Configuration Question

Redirect subfolder requests to subfolder

I have a setup where I can only access the root of a domain (subdomains are not allowed due to restrictive firewall policies). Lets say the domain is

www.domain.com
, for testing i have a symlinked a folder in
/var/www/testing
that points to several html and css files. In these files, scripts and css are included like e.g.

<link rel="stylesheet" href="/css/app.css">

which will fail as apache looks for the file in
www.domain.com/css/app.css
while it resides in
www.domain.com/testing/css/app.css
is there a possibility with .htaccess or RewriteEngine to make all requests (for css and js files) coming from
/testing/
also going to
/testing/...
like examplified above?

Answer

Try

RedirectMatch ^/(css/.+\.css)$ /testing/$1

This will redirect /css/file.css to /testing/css/file.css