Remapping subdirectories can be useful when either re-structuring your site or giving access to other users to alter specific subdirectories without needing to give them full access to the site. By using this feature, users have subdirectories of their sites use non-standard locations within the file structure as a new source for web content.
- You cannot use the remap subdirectory service to change the web directory for an entire domain. To change the entire web directory, you must edit the domain from the ‘Manage Domains’ page.
- Only the username used to remap the subdirectory has access to that directory, and not the original owner. This means that while multiple users could each have folders assigned to them, they cannot share access to the same folder. This is illustrated in the following image:
- It’s not possible to remap directories across different servers.
CGI scripts won't work in subdirectories remapped to other user's home directories because of file ownership issues.
PHP scripts won't work in subdirectories remapped to other user's home directories because of PHP security limitations. Trying to run a script across users just loads a blank page with "No input file specified".
PHP scripts in remapped subdirectories (within your own home directory) can only run with the server's default PHP version.
How to remap a subdirectory
Confirming the two web directories to remap
In the following example, the remapexample.dreamhosters.com/pictures subdirectory will be remapped to a different domain and directory named example.com/newpics.
Finding the web directory of the primary domain
To find the web directory:
- Navigate to the (Panel > ‘Domains’ > ‘Manage Domains’) page.
- Click the Edit button to the right of your domain.
- Under the ‘Users, Files, and Paths’ section, find the ‘Web directory:’ field. Use this directory path to your website.
- This domain is remapexample.dreamhosters.com and the user associated with the domain is dh_user
- The ‘Web directory’ is /home/dh_user/remapexample.dreamhosters.com meaning that Internet traffic would go to that directory when attempting to reach the main site.
- If someone navigates to remapexample.dreamhosters.com/pictures, then according to the web directory set up already they would be directed to /home/dh_user/remapexample.dreamhosters.com/pictures for content.
By remapping subdirectories, visitors would not need to use that folder as the source for pictures. A user could give someone else access to their /pictures folder to update it without giving full FTP access
Finding the web directory of the domain to remap
Use the same directions above to find the web directory for the domain you’re going to use to remap.
- example_username is the user for the domain.
- This means that the full path to the /newpics folder would be /home/example_username/example.com/newpics.
Remapping the subdirectory
Once you know the web directories for both domains, you can proceed with remapping the subdirectories.
- Navigate to (Panel > ‘Domains’ > ‘Remap-Sub-Dir’).
- Choose your domain from the dropdown list.
- In the field to the right, type in the directory you wish to remap.
- Click the Continue… button.
- Make the following selections:
- URL to remap: This is automatically filled in by what was entered in the previous step
- New path on [servername]: Choose your second username from the dropdown. Then type in the full path to the second domain to remap.
- Click the Remap this sub-directory! button to save. This may take up to 15 minutes to update on the server.
In this example, remapexample.com/pictures is remapped to example.com/newpics.
- or in terms of file path:
/home/dh_user/remapexample.dreamhosters.com/pictures now references /home/example_username/example.com/newpics for web content.
Viewing the final result
When logging in to the original directory via FTP, you see the following files:
Note the two files:
When logging in to the second remapped domain’s directory via FTP, you see the following files:
Note the two files:
However, if you now visit the original domain of remapexample.dreamhosters.com/pictures through a web browser, only the files for the second remapped directory show:
If this subdirectory was not remapped, the Desert.jpg and Chrysanthemum.jpg photos would be showing instead.
This means that although the original user still has access to the file structure, changes made in it no longer show online since this subdirectory no longer belongs to the original user. The second user for the remapped subdirectory controls this subfolder.
- As you can see in the above screenshot, there is another folder named /test2 within the directory that ended up being remapped. At this point, the test2 directory and anything within it as well would not be accessible online as traffic is no longer going to that directory.
- Further directories can only be added to the remapped subdirectory controlled by the second username.