Skip to content

Instantly share code, notes, and snippets.

@earth3300
Last active March 5, 2020 21:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save earth3300/908eef5a154831472ce8b87f8c3d22ee to your computer and use it in GitHub Desktop.
Save earth3300/908eef5a154831472ce8b87f8c3d22ee to your computer and use it in GitHub Desktop.
ROOT directory .htaccess script when ALL files are in sub-directory.
# ALWAYS rewrite to the specified directory (excluding the directory itself).
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{REQUEST_URI} !^/main/
RewriteRule ^(.*)$ /main/$1
</IfModule>
@earth3300
Copy link
Author

earth3300 commented Mar 5, 2020

This short script was developed to handle the case where ALL server files are placed in directories, INCLUDING the files belonging to the root directory. Typically, the default behaviour is to have placed the files belonging to the MAIN domain associated with an account in the ROOT. Although this is convenient for this domain, it leads to problems (at least of a visual nature), when subsequent domains are added to the same account. Again, the default behaviour is to place these subsequent domains in subdirectories, thus making them children of the main domains's directory (typically public_html).

The alternative is to place files for additional domains or sub-domains as a peer of public_html. This ALSO leads to problems as SOME files at this level are not meant to be accessed. The logical solution would be to make the directory in which the files for the MAIN domain associated with an account available to be specified. The current default behaviour is that the directory for the MAIN domain CANNOT be specified, meaning that they MUST be in the root. With these constraints (other than moving to a virtual server over which one has full control) is to place this script in the ROOT of /public_html and then treat all domains and sub-domains as PEERs; including the main domain associated with an account.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment