Apache / .htaccess Integration Methods:

Simple Content Folder

Simple Content Folder Limitations:

  • No Redirect Support


The easiest integration method serves fully generated HTML files out of an Apache website.

  1. In the jsHarmony CMS, on the Sites tab, create a new Site

  2. In the Site Settings, add a Deployment Target:
    1. Configure the Deployment Target to publish to the Apache website folder
    2. Set the URL Prefix to "/" if CMS files will be available off the root of the target domain, or otherwise set URL Prefix to the path prefix

  3. Create a Page Template:
    1. Local Page Templates can be defined in the CMS, by using the Site's SFTP
    2. Remote Page Templates can be defined in a subfolder of the Apache website, and linked to the CMS in the Site Settings "Page Templates" tab.
      :: Configuring Remote Page Templates

  4. Add CMS content and publish to the Deployment Target, generating HTML files in the Apache website folder

Serving a Subfolder as Root

In some situations, it may be helpful to store the CMS content files in the subfolder of the Apache website, but still serve the files to the user as if they were in the root of the site.

The following additional steps can help to serve an Apache website subfolder as root:

  1. In the jsHarmony CMS, on the Sites tab, create a new Site

  2. In the jsHarmony CMS, in the Site Settings, edit the Deployment Target:
    1. Set "URL Prefix" to the subfolder where the published files will be stored, ex: "/content/"
    2. Set "Override Page URL Prefix" to the root of the site, ex: "/"

  3. Add the following code to the .htaccess file:
    # Apache Server mod_rewrite Example
    # :: Serve a subfolder as if it was the root of the site
    RewriteCond %{DOCUMENT_ROOT}/published_files_subfolder/%{REQUEST_URI} -f
    RewriteRule ^(.*) /published_files_subfolder/$1 [L]
    RewriteCond %{DOCUMENT_ROOT}/published_files_subfolder/%{REQUEST_URI} -d
    RewriteRule ^(.*) /published_files_subfolder/$1/ [L]

Redirects

Redirects can be implemented in Apache by generated a .htaccess file at publish time:

  1. Download the jsHarmony .htaccess Component, and extract it into your site's SFTP folder, into the "templates\components" subfolder.

  2. Modify the .htaccess Component as necessary - add additional .htaccess directives above or below the redirect code.

  3. Add redirects on the CMS "Pages" > "Redirects" grid, and publish to generate the .htaccess file

Redirect Regular Expression Syntax

The syntax for Redirect regular expressions is specific to the deployment environment.  When using .htaccess deployment, be sure to use the Apache mod_redirect Regular Expression syntax.

Below is an example of RegEx variable replacement, using the jsHarmony .htaccess Component:

URL:         ^products/([a-zA-Z]*)$
Destination: /view_product?id=$1
Loading
Loading