---
title: "Maintaining a static microsite alongside Drupal's docroot"
date: "2024-01-08T04:58:25+00:00"
summary:
image:
type: "article"
url: "/acquia-cloud-platform/help/92231-maintaining-static-microsite-alongside-drupals-docroot"
id: "5902066c-4d40-4f73-9827-95de452c72c1"
---

Issue
-----

There may be times when you want to serve a "Coming soon" page or some other small amount of content from inside your Drupal docroot. Situations can include running a separate lightweight landing page, or a flat HTML/CSS/JavaScript brochureware website.

Resolution
----------

You have a few options to serve a static HTML microsite from your Drupal docroot, including either as part of the code repository where you manage them using a version control system (such as Git) or in the files directory where you manage them using `sFTP` or `rsync`. In general, you should have only a small set of pages that have minimal impact.

![I'm sorry, I can't see the image you're referring to. Could you describe it for me?](https://acquia.widen.net/content/a3844578-5e0f-4464-b5be-907862aded80/web/ka0Pb0000000Lin00N6g00000VCdgi0EMPb000001DxMf.png)

   
As part of **Drupal 7.24 or higher**, if the recommended [Drupal `.htaccess`](https://git.drupalcode.org/project/drupal/-/blob/10.1.x/.htaccess?ref_type=heads) files are in place, PHP files will **not be executable** in subdirectories, with the exception of the `docroot/static` directory.

 

![I'm sorry, I can't see the image you're referring to. Could you describe it for me?](https://acquia.widen.net/content/a3844578-5e0f-4464-b5be-907862aded80/web/ka0Pb0000000Lin00N6g00000VCdgi0EMPb000001DxMf.png)

   **Important**  
**Add an** `.htaccess` **file inside the directory with your microsite, for example, the static folder that contains the following code:**

    RewriteEngine On
    RewriteRule ^$ index.html [L]

###   
  
Make uploaded files appear as a docroot subdirectory

To serve a static HTML website in a subdirectory of a domain (such as `example.com/static`), you can commit or push an additional directory containing your HTML, CSS, JavaScript, and image files into your code repository.

Alternatively, you can manage your files using a tool, such as `sFTP` or `rsync`, to copy the static files into your `sites/*/files` directory and redirect requests for a simple path to reference those files instead. This allows you to keep your repository free of changes to non-Drupal files and may make it easier for non-developers to update files, such as images.

In your docroot `.htaccess` file, you can use the following code pattern, which you will need to deploy using your Drupal Git repository, in your rewrite rules section (generally between the and tags):

    # any paths beginning with the path /static/ (not case sensitive)...
    RewriteCond %{REQUEST_URI} ^/static/ [NC]
    # Pass-through the matching file from beneath /sites/default/files/SOME-FOLDER and stop processing
    RewriteRule ^static/(.*)$ /sites/default/files/folder-with-static-content/$1 [PT,L]

Make sure you place your custom changes directly before the following code snippet in your `.htaccess` file; otherwise, the changes will come too late in the file:

    # Pass all requests not referring directly to files in the filesystem to
    # index.php. Clean URLs are handled in drupal_environment_initialize().
    RewriteCond %{REQUEST_FILENAME} !-f 
    RewriteCond %{REQUEST_FILENAME} !-d 
    RewriteCond %{REQUEST_URI} !=/favicon.ico
    RewriteRule ^ index.php [L]

###   
  
Run the site on a separate domain

If you need to have pages on `domain-b.com` until a new Drupal website or multisite is ready, while continuing to operate your Drupal website on `domain-a.com`, you can achieve this by uploading the static website files, and then adding the following code to your `docroot/.htaccess` file:

![I'm sorry, I can't see the image you're referring to. Could you describe it for me?](https://acquia.widen.net/content/a3844578-5e0f-4464-b5be-907862aded80/web/ka0Pb0000000Lin00N6g00000VCdgi0EMPb000001DxMf.png)

   **Note for Acquia Cloud users**  
On Acquia Cloud, you will need to add a domain or subdomain to your **[Domains page](/node/57277)** for this to work.

    # Only serve the static site for a particular host.
    RewriteCond %{HTTP_HOST} ^domain-b\.com$
    
    # Don't loop anything targeting the actual mask directory, to allow
    # for linked scripts, stylesheets etc in the static HTML
    RewriteCond %{REQUEST_URI} !^/static/
    
    #Any requests that made it this far are served from the /static/ directory
    RewriteRule ^(.*)$ /static/$1 [PT]

###   
  
Combining the two methods

You can combine these two methods to direct a domain to a static HTML website contained in the file system instead of in the code repository. This is particularly useful either if you have a team that needs to be able to update HTML files and is only familiar with `sFTP`, or if the static website includes large files.

    RewriteCond %{HTTP_HOST} ^domain-b\.com$
    
    # Don't loop anything targeting the actual mask directory, to allow
    # for linked scripts, stylesheets etc in the static HTML
    RewriteCond %{REQUEST_URI} !^/sites/default/files/static/
    
    # pass-through the matching file from beneath /sites/default/files/ and stop processing
    RewriteRule ^(.*)$ /sites/default/files/static/$1 [PT,L]

![I'm sorry, I can't see the image you're referring to. Could you describe it for me?](https://acquia.widen.net/content/a3844578-5e0f-4464-b5be-907862aded80/web/ka0Pb0000000Lin00N6g00000VCdgi0EMPb000001DxMf.png)

  
If your site is redirecting all traffic to **https** on a canonical domain (e.g., redirecting from [http://example.com](http://example.com/)  to [https://www.example.com](https://www.example.com)), ensure that the redirect code in your `docroot/.htaccess` file is added _**before**_ any rewrites for the static microsite.

###   
  
  
Set Up a "Coming Soon" Page

There are some options available display a single page to your visitors while you site is under construction for a single domain:

1.  If the domain is launching but the entire site is not accessible, you could create a new branch with no Drupal code and place the `index.html` and assorted files in the docroot. An example of this would be the code deployed from the `tag/WELCOME` tag inside your Acquia repository.
2.  Create a page via Drupal. Visit the **Basic Site Settings** page at `/admin/config/system/site-information` and set the **Default front page** to that node.
3.  Create a [symlink](https://support.acquia.com/hc/en-us/articles/360005761294-Adding-flexibility-to-your-server-structure-using-symlinks) of `index.html` in the docroot pointing to the `index.html` file within the `sites` directory. You'll probably need to use full URLs in the CSS and JS links to account for the symlink.