Enabling Apache Rewrite Module on AEM Cloud Instances | Community
Skip to main content
Rohan_Garg
New Participant
July 30, 2022
Solved

Enabling Apache Rewrite Module on AEM Cloud Instances

  • July 30, 2022
  • 1 reply
  • 1611 views

Hi All,

 

I have deployed my vhost file on AEM Cloud which is working fine for most part save the redirection rules.

Snippet from vhost file - 

<IfModule mod_rewrite.c>
RewriteEngine On

RewriteRule ^/$ /content/xyz/us/en/home-page.html [PT,L]

RewriteRule    "^/content/xyz/us/en/home-page.html"  "/content/xyz/us/en/xyz-home-page.html" [PT]

 

# Add .html extension when extension is missing from request
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([^.]*[^./])$ $1.html [R=301,L]

 

As you can see I have written 3 redirects here - 

1. Redirecting Root URL '/' to home-page.html

2. Redirecting Page A to Page B

3. Adding .html when missing in request

 

None of these redirects are working.

 

Previously on Apache Webserver, we had to uncomment rewrite module in /etc/apache2/httpd.conf.

But with Cloud Instance we no longer have access to those configuration files.

 

Does Adobe enable the rewrite module by default on the webserver ? 

or Does it have to be manually enabled by raising a ticket ?

 

Can anyone please advise on this ?

@user05162 , @nupur_jain , @arunpatidar , @kautuk_sahni 

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Best answer by arunpatidar

Hi,

It does have the rewrite module enabled

<IfModule mod_rewrite.c>
		RewriteEngine	on
		Include conf.d/rewrites/rewrite.rules

		# Rewrite index page internally, pass through (PT)
		RewriteRule "^(/?)$" "/index.html" [PT]

	</IfModule>

You must try updating rewrite rules in conf.d/rewrites/rewrite.rules file
I have tested this with aem-dispatcher-sdk
more info on how to use dispatcher-sdk which is replica of AEMaaCS dispatcher configuration.

https://experienceleague.adobe.com/docs/experience-manager-learn/cloud-service/local-development-environment-set-up/dispatcher-tools.html 

1 reply

arunpatidar
arunpatidarAccepted solution
New Participant
July 30, 2022

Hi,

It does have the rewrite module enabled

<IfModule mod_rewrite.c>
		RewriteEngine	on
		Include conf.d/rewrites/rewrite.rules

		# Rewrite index page internally, pass through (PT)
		RewriteRule "^(/?)$" "/index.html" [PT]

	</IfModule>

You must try updating rewrite rules in conf.d/rewrites/rewrite.rules file
I have tested this with aem-dispatcher-sdk
more info on how to use dispatcher-sdk which is replica of AEMaaCS dispatcher configuration.

https://experienceleague.adobe.com/docs/experience-manager-learn/cloud-service/local-development-environment-set-up/dispatcher-tools.html 

Arun Patidar
Rohan_Garg
New Participant
August 2, 2022

Hi @arunpatidar , Thanks for your response.

Putting the rewrite rule in the rules file worked as against putting it in vhost file.

However, in another thread as discussed I am unable to separate the rewrite rules file for different sites even with the opt-in folder and USE_SOURCES_DIRECTLY file present.

I am getting the file cannot be found when I run dispatcher validator in non-relaxed mode.

 

When deployed on cloud instance, the rewrite rule is not redirecting the pages as expected.
Any help on this ?
Original Link - https://experienceleaguecommunities.adobe.com/t5/adobe-experience-manager/how-to-have-more-than-1-rewrite-rules-file-in-aem-as-a-cloud/td-p/427400