Search code examples
apache.htaccesswebsubdirectory

Making a subdirectory independent using the .htaccess file


Let's say that I have a subdirectory in my www folder called subdirectory. Is it possible to modify the .htaccess file so that all files contained within the subdirectory can be referenced inside other files like this: /somefile.extension? Therefore, I'd like the subdirectory to act as the root for all files inside it, and I don't want to use a subdomain.


Solution

  • Try this:

    RewriteEngine on
    RewriteCond %{HTTP_REFERER} ^http://site.com/subdirectory/
    RewriteCond %{REQUEST_URI} !^/subdirectory/
    RewriteRule (.*) /subdirectory/$1 [L,QSA]