July 3, 2026

Hide the /content Root Path in AEM Publish and Website URLs

Apache redirect in AEM

It is good practice to hide the content path from the public domain and from publish server URLs. Here is one of the best approaches.

Say the website is on this public URL:

https://[websitename.com]/content/sitename/fr/home.html

and AEM serves it at:

http://<hostname>:<port>/content/sitename/fr/home.html

The recommended practice is to keep /content/sitename out of the public URL. That takes configuration on both the publish instance and the dispatcher.

Configuration on publish

Configure the Apache Sling Resource Resolver Factory so URLs are rewritten on the publish server. Add these entries under URL Mappings:

/content/sitename/(.*)</$1
/content/sitename/fr$1>/fr(.*)

Save the configuration and open http://<hostname>:<port>/fr/home.html — the home page loads on publish without /content/sitename. After saving, the relevant bundles take a little while to restart.

Configuration on the dispatcher

Publish now answers without the content path. Next, make the public domain behave the same way through the dispatcher.

Step 1. Make sure the mod_rewrite module is loaded in Apache:

#
# This file loads most of the modules included with the Apache HTTP server
#
LoadModule rewrite_module modules/mod_rewrite.so

Step 2. Set DispatcherUseProcessedURL to 1 so the dispatcher uses the processed (rewritten) URLs:

<IfModule disp_apache.c>
    # Enabled so that rewrites take effect
    DispatcherUseProcessedURL 1
</IfModule>

Step 3. Add these rules to the virtual host file (usually under conf.d):

<IfModule mod_rewrite.c>
    RewriteEngine on

    RewriteRule ^(.+)/$ $1

    # Shorten the URL
    RewriteRule ^/content/sitename/(.*).html$ $1.html [R,L]
    # Redirect the root to the fr home page
    RewriteRule ^/?$ fr/home.html [R,L]
</IfModule>

Restart Apache and open https://[websitename.com]/fr/home.html — the home page loads without the content path.

The same resource resolver mapping technique serves a robots.txt from the DAM.