How to: Manage Advanced Settings via .htaccess in SiteWorx

An htaccess file provides the ability for SiteWorx administrators to override some global web server settings for their specific directory in plain text. This file can be used to modify redirects, Apache Handlers, MIME-Types, character sets, and PHP Variables.

To Manage the .htaccess File

Adding a Global .htaccess File

Options set in a Global .htaccess file will affect the entire site, including subdomains. The .htaccess file will be installed into the webroot of the domain.

  1. Log into SiteWorx in the browser (https://ip.ad.dr.ess:2443/siteworx)

  2. In SiteWorx, navigate to Hosting Features > Htaccess, either from the side menu or SiteWorx home

  3. Next to Global Directory Options, click +. This opens the Add .htaccess File form

    siteworx add htaccess
  4. Click Add

Adding a Directory Specific .htaccess File

Options set in a Directory Specific .htaccess file will only affect files within the corresponding directory, including its subdirectories.

  1. Log into SiteWorx in the browser (https://ip.ad.dr.ess:2443/siteworx)

  2. In SiteWorx, navigate to Hosting Features > Htaccess, either from the side menu or SiteWorx home

  3. Next to Per Directory Options, click +. This opens the Add .htaccess File form

  4. Update the required fields:

    • Directory: The full path to the desired directory

    • Status: If the htaccess file should be enabled or disabled

    siteworx add per directory htaccess
  5. Click Add

Enabling an .htaccess File

  1. Log into SiteWorx in the browser (https://ip.ad.dr.ess:2443/siteworx)

  2. In SiteWorx, navigate to Hosting Features > Htaccess, either from the side menu or SiteWorx home

  3. Click the Pencil next to the desired htaccess file. This opens the Directory Options Management page

  4. Under Action, click . This opens a popup

  5. Click Enable. This opens the Confirmation form

  6. Click OK

Disabling an .htaccess File

  1. Log into SiteWorx in the browser (https://ip.ad.dr.ess:2443/siteworx)

  2. In SiteWorx, navigate to Hosting Features > Htaccess

  3. Click the Pencil next to the desired htaccess file. This opens the Directory Options Management page

  4. Under Action, click . This opens a popup

  5. Click Disable. This opens the Confirmation form

  6. Click OK

Deleting a Global .htaccess File

  1. Log into SiteWorx in the browser (https://ip.ad.dr.ess:2443/siteworx)

  2. In SiteWorx, navigate to Hosting Features > Htaccess, either from the side menu or SiteWorx home

  3. Under Global Directory Options, click the Trashcan next to the desired htaccess file. This opens the additional input form

    siteworx delete global htaccess
  4. Select the htaccss to delete. This opens the Confirmation form

  5. Click Delete

Deleting a Directory Specific .htaccess File

  1. Log into SiteWorx in the browser (https://ip.ad.dr.ess:2443/siteworx)

  2. In SiteWorx, navigate to Hosting Features > Htaccess

  3. Under the Per Directory Options heading, click the Trashcan next to the desired htaccess file. This opens the Confirmation form

    siteworx domain specific htaccess delete form
  4. Click Delete

To Add or Edit .htaccess Access Control

  1. Log into SiteWorx in the browser (https://ip.ad.dr.ess:2443/siteworx)

  2. In SiteWorx, navigate to Hosting Features > Htaccess, either from the side menu or SiteWorx home

  3. Click the Pencil next to the desired htaccess file. This opens the Directory Options Management page

  4. Under Action,cClick the Globe. This opens the Global Access Control form

  5. Update the desired fields:

    • Access Order: Set the order in which the Trusted (Allow) and Blocked

      • Deny first, then allow - The ‘Blocked Hosts’ list will be evaluated first.

      • Allow first, then deny - The ‘Trusted Hosts’ list will be evaluated first.

    • Trusted Hosts: IPs or domain names that will be allowed access to the directory and its subdirectories

    • Blocked Hosts: IPs or domain names that will be denied access to the directory and its subdirectories

    siteworx htaccess global access form
  6. Click Update

To Manage Error Document Settings

Configure apache to serve up custom error documents. Choose the error code and specify the page (either relative to the current directory, or relative to the webroot).

Adding an Error Document

  1. Log into SiteWorx in the browser (https://ip.ad.dr.ess:2443/siteworx)

  2. In SiteWorx, navigate to Hosting Features > Htaccess, either from the side menu or SiteWorx home

  3. Click the Pencil next to the desired htaccess file. This opens the Directory Options Management page

  4. Under Error Documents, click +. This will open the Add ErrorDocument form

  5. Update the required fields:

    • Error Code: The error code to direct to a custom page

    • Error Page: The page to redirect to upon an error code

    siteworx htaccess add error document form
  6. Click Save

Editing an Error Document

  1. Log into SiteWorx in the browser (https://ip.ad.dr.ess:2443/siteworx)

  2. In SiteWorx, navigate to Hosting Features > Htaccess, either from the side menu or SiteWorx home

  3. Click the Pencil next to the desired htaccess file. This opens the Directory Options Management page

  4. Under Error Documents, click Pencil next to the desired Error Document to edit. This will open the Edit ErrorDocument form

  5. Update the Error Page field

    siteworx htaccess edit error document form
  6. Click Save

Deleting an Error Document

  1. Log into SiteWorx in the browser (https://ip.ad.dr.ess:2443/siteworx)

  2. In SiteWorx, navigate to Hosting Features > Htaccess, either from the side menu or SiteWorx home

  3. Click the Pencil next to the desired htaccess file. This opens the Directory Options Management page

  4. Under Error Documents, click Trashcan next to the desired Error Document to delete. This will open the confirmation form

    siteworx htaccess delete error document form
  5. Click Delete

To Manage MIME-Type Settings

Add custom MIME-Types and associated extensions. MIME-Types must be in the form: “<type>/<subtype>”. It is possible to enter more than one extension in the “Extensions” field, separated by either spaces or commas.

Adding a MIME-Type

  1. Log into SiteWorx in the browser (https://ip.ad.dr.ess:2443/siteworx)

  2. In SiteWorx, navigate to Hosting Features > Htaccess, either from the side menu or SiteWorx home

  3. Click the Pencil next to the desired htaccess file. This opens the Directory Options Management page

  4. Under Mime-Types, click +. This will open the Add Mimetype form

  5. Update the required fields:

    • MIME-Type: The type of file

    • Extensions: The extensions of the file type

    siteworx htaccess add mime-type form
  6. Click Save

Editing a MIME-Type

  1. Log into SiteWorx in the browser (https://ip.ad.dr.ess:2443/siteworx)

  2. In SiteWorx, navigate to Hosting Features > Htaccess, either from the side menu or SiteWorx home*

  3. Click the Pencil next to the desired htaccess file. This opens the Directory Options Management page

  4. Under Mime-Types, click Pencil next to the desired Mime-Type definition. This will open the Edit Mimetype form

  5. Update the Extensions field

    siteworx htaccess edit mime-type form
  6. Click Save

Deleting a MIME-Type

  1. Log into SiteWorx in the browser (https://ip.ad.dr.ess:2443/siteworx)

  2. In SiteWorx, navigate to Hosting Features > Htaccess, either from the side menu or SiteWorx home

  3. Click the Pencil next to the desired htaccess file. This opens the Directory Options Management page

  4. Under Mime-Types, click Trashcan next to the desired Mime-Type to delete. This will open the confirmation form

    siteworx htaccess delete mime-type form
  5. Click Delete

To Manage Apache Handlers

Add custom handlers and associated extensions. Handlers determine how a file with the associated extension is served by Apache. It is possible to enter more than one extension in the “Extensions” field, separated by either spaces or commas.

Adding an Apache Handler

  1. Log into SiteWorx in the browser (https://ip.ad.dr.ess:2443/siteworx)

  2. In SiteWorx, navigate to Hosting Features > Htaccess, either from the side menu or SiteWorx home

  3. Click the Pencil next to the desired htaccess file. This opens the Directory Options Management page

  4. Under Handlers, click +. This will open the Add Handler form

  5. Update the required fields:

    • Handler: Action to be performed on the file

    • Extensions: The file extension

    siteworx htaccess add handler form
  6. Click Save

Editing an Apache Handler

  1. Log into SiteWorx in the browser (https://ip.ad.dr.ess:2443/siteworx)

  2. In SiteWorx, navigate to Hosting Features > Htaccess, either from the side menu or SiteWorx home

  3. Click the Pencil next to the desired htaccess file. This opens the Directory Options Management page

  4. Under Handlers, click Pencil next to the desired Handler definition. This will open the Edit Handler form

  5. Update the Extensions field

    siteworx htaccess edit handler form
  6. Click Save

Deleting an Apache Handler

  1. Log into SiteWorx in the browser (https://ip.ad.dr.ess:2443/siteworx)

  2. In SiteWorx, navigate to Hosting Features > Htaccess, either from the side menu or SiteWorx home

  3. Click the Pencil next to the desired htaccess file. This opens the Directory Options Management page

  4. Under Handlers, click Trashcan next to the desired Handler to delete. This will open the confirmation form

    siteworx htaccess delete handler form
  5. Click Delete

To Manage Default Character Sets

Setting or Editing the Default Character Set

  1. Log into SiteWorx in the browser (https://ip.ad.dr.ess:2443/siteworx)

  2. In SiteWorx, navigate to Hosting Features > Htaccess, either from the side menu or SiteWorx home

  3. Click the Pencil next to the desired htaccess file. This opens the Directory Options Management page

  4. Under Action, click the XA. This opens the Default Character set form

  5. Update the Default Character Set field

    siteworx htaccess default character set add form
  6. Click Save

Removing the Default Character Set

  1. Log into SiteWorx in the browser (https://ip.ad.dr.ess:2443/siteworx)

  2. In SiteWorx, navigate to Hosting Features > Htaccess, either from the side menu or SiteWorx home

  3. Click the Pencil next to the desired htaccess file. This opens the Directory Options Management page

  4. Under Action, click the XA. This opens the Default Character set form

  5. Delete all information in the Default Character Set field

  6. Click Save

To Manage Redirect Rules

Redirect one URL to a new URL. The “Redirect From” field takes a path relative to the web root, while the “Redirect To” takes an absolute URL to another site.

Adding a Redirect Rule

  1. Log into SiteWorx in the browser (https://ip.ad.dr.ess:2443/siteworx)

  2. In SiteWorx, navigate to Hosting Features > Htaccess, either from the side menu or SiteWorx home

  3. Click the Pencil next to the desired htaccess file. This opens the Directory Options Management page

  4. Under Redirects, click +. This opens the Add Redirect form

  5. Update the required fields:

    • Redirect From: the relative directory to redirect. Examples: /, /old-site

    • Redirect To: the URL of the site to redirect to. Examples: https://new-site.com/, http://google.com

    • Redirect Type: The type of redirect that will be set:

      • Temporary: Returns a temporary redirect status (302). This is the default

      • Permanent: Returns a permanent redirect status (301) indicating that the resource has moved permanently

      • See Other: Returns a “See Other” status (303) indicating that the resource has been replaced

      • Gone: Returns a “Gone” status (410) indicating that the resource has been permanently removed. When this status is used the URL argument should be omitted

      • Please see the Apache documentation for more detailed information about redirect types

    siteworx htaccess add redirect form
  6. Click Save

Editing a Redirect Rule

  1. Log into SiteWorx in the browser (https://ip.ad.dr.ess:2443/siteworx)

  2. In SiteWorx, navigate to Hosting Features > Htaccess, either from the side menu or SiteWorx home

  3. Click the Pencil next to the desired htaccess file. This opens the Directory Options Management page

  4. Under Redirects, click Pencil next to the desired Redirect definition. This will open the Edit Redirect form

  5. Update the Redirect To and Redirect Type fields

    siteworx htaccess redirect edit form
  6. Click Save

Deleting a Redirect Rule

  1. Log into SiteWorx in the browser (https://ip.ad.dr.ess:2443/siteworx)

  2. In SiteWorx, navigate to Hosting Features > Htaccess, either from the side menu or SiteWorx home

  3. Click the Pencil next to the desired htaccess file. This opens the Directory Options Management page

  4. Under Redirects, click Trashcan next to the desired Redirect to delete. This will open the confirmation form

    siteworx delete redirect form
  5. Click Delete

To Manage Indexes

  1. Log into SiteWorx in the browser (https://ip.ad.dr.ess:2443/siteworx)

  2. In SiteWorx, navigate to Hosting Features > Htaccess, either from the side menu or SiteWorx home

  3. Click the Pencil next to the desired htaccess file. This opens the Directory Options Management page

  4. Under Action, click the List. This opens the Index Management form

  5. Update the required fields:

    • Default Index Files: This setting affects when a browser requests a URL that ends in / (a directory). Apache will use this list of files to determine which file to server. Apache will server the first file found in the list from top to bottom

    • Directory Listing: This setting affects when a browser requests a URL that ends in a ‘/’ (a directory), and no Default Index files are found:

      • No: The browser will receive a ‘403 Forbidden’ response

      • Yes: The browser will list the contents of the directory

      • Inherited: The setting will be inherited from a parent directory

    • Directory Listing Style: This setting affects how the directorylisting will be displayed:

      • Simple Listing: A simple directory list of files will be displayed

      • Fancy Listing: A directory list of files along with timestamps and file sizes will be displayed

      • Inherited: The setting will be inherited from a parent directory

    siteworx htaccess add index form
  6. Click Update

To Add Custom .htaccess Rules From the CLI

Customers may add their own .htaccess rules to the top of any .htaccess file generated by InterWorx.

Note

SiteWorx users must have shell access provided to them by the server administrator in order to access the CLI.

  1. Log in to the server at the CLI, either as root (if the server administrator), or the SiteWorx user (if shell access has been granted), either via SSH or from the terminal

  2. Using a text editor, open the .htaccess file for the account. It is most likely located in /home/{unixuser}/{domain.com}/html/.htaccess, replacing {unixuser} and {domain.com} with the corresponding information. The following example uses the vim text editor

    vim /home/domainco/domain.com/html/.htaccess
    
  3. Add the desired custom rules to the top of the file. There is a message built into the file that states where to add any manual edits

    # ALL CUSTOM ENTRIES SHOULD GO ABOVE THIS LINE
    # BEGIN IWORX header
    
  4. Save the file and exit the text editor