Remap Sub-Dir

From DreamHost
Jump to: navigation, search

Overview

Remapping subdirectories can definitely be useful when it comes to 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.

Limitations

  • 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 will have 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.
  • It’s not possible to remap directories across different servers.

CGI

CGI scripts won't work in subdirectories remapped to other user's home directories because of file ownership issues.

PHP

PHP scripts won't work in subdirectories remapped to other user's home directories because of a PHP security update DreamHost admins implemented in March 2012. Trying to run a script across users just loads a blank page with "No input file specified".

Note2 icon.png Note: 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 you’ll use to remap

In the following example, the remapexample.dreamhosters.com/pictures subdirectory will be remapped to a different domain and directory named dhwiki.dreamhosters.com/newpics.

Finding the web directory of the primary domain

To find the web directory:

  1. Navigate to the (Panel > ‘Domains’ > ‘Manage Domains’) page.
  2. Click the Edit button to the right of your domain.
    01 remap subdir.fw.png
  3. Under the ‘Users, Files, and Paths’ section, find the ‘Web directory:’ field. You will 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 looking 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.

02 remap subdir.fw.png
  • dhwikiuser is the user for the domain.
  • This means that the full path to the /newpics folder would be /home/dhwikiuser/dhwiki.dreamhosters.com/newpics.

Remapping the subdirectory

Once you know the web directories for both domains, you can proceed with remapping the subdirectories.

  1. Navigate to (Panel > ‘Domains’ > ‘Remap-Sub-Dir’).
    03 remap subdir.fw.png
  2. Choose your domain from the dropdown list.
  3. In the field to the right, type in the directory you wish to remap.
  4. Click the Continue… button.
    04 remap subdir.fw.png
  5. 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, and then type in the full path to the second domain you’ll use to remap.
  6. Click the Remap this sub-directory! button to save. This may take up to 15 minutes to update on the server.
    Note2 icon.png Note: In this example, remapexample.dreamhosters.com/pictures is remapped to dhwiki.dreamhosters.com/newpics.
    or in terms of file path:

    /home/dh_user/remapexample.dreamhosters.com/pictures will now reference /home/dhwikiuser/dhwiki.dreamhosters.com/newpics for web content.


Viewing the final result

When logging in to the original directory via FTP, you'll see the following files:

05 remap subdir.fw.png

Note the two files:

  • Desert.jpg
  • Chrysanthemum.jpg

When logging in to the second remapped domain’s directory via FTP, you'll see the following files:

06 remap subdir.fw.png

Note the two files:

  • Lighthouse.jpg
  • Koala.jpg

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 will show:

07 remap subdir.fw.png

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.

Note2 icon.png Notes:
  • 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, that 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.