How to have more than 1 rewrite.rules file in aem as a cloud dispatcher
I have created opt-in/USE_SOURCES_DIRECTLY but still its throwing validation errors following this document
https://experienceleague.adobe.com/docs/experience-manager-cloud-service/implementing/content-delive...
Any help on remaining part of the process would be great to have
Solved! Go to Solution.
Hi,
According to the troubleshooting docs, the custom rewrite rules can be added into rewrite.rule and defualt_rewrite.rule is optional to add.
There are two types of files in your Apache virtual host configuration that can be specified as includes: rewrites and variables. The included files need to be named as follows:
Type Include file name
Rewrites | conf.d/rewrites/rewrite.rules |
Variables | conf.d/variables/custom.vars |
Alternatively, you can include the default version of the rewrite rules, whose name is conf.d/rewrites/default_rewrite.rules. Note, that there is no default version of the variables files.
And as you already mentioned that the new flexible mode does not have this limitation, did you tried with new Flexible mode
Flexible mode - the recommended mode, and the default for AEM archetype 28 and higher, which is also used by Cloud Manager for new environments created after the Cloud Manager 2021.7.0 release. Customers can activate this mode by adding the folder and file opt-in/USE_SOURCES_DIRECTLY. By using this more flexible mode, there are no limitations in the file structure under the rewrites folder that in legacy mode required a single rewrite.rules file. Also, there is no limitation on the number of rules you can add. For for details on folder structure and local validation see Validating and Debugging using Dispatcher Tools.
Legacy mode - for details on the folder structure and local validation for dispatcher configuration legacy mode, see Validating and Debugging using Dispatcher Tools (Legacy)
Hi @Ralph8 ,
There is no much diffrence in normal dispatcher and Adobe cloud dispatcher.
In Adobe cloud dispatcher you need to add your rewrite file and use dispatcher validater to make the correction of path.
Regards,
Sanjay
Hi @Sanjay_Bangar,
The dispatcher validator is breaking here when its finding a different rewrite.rule file.
Just trying to understand how to add multiple rewrite.rules because the validator is performing some checks to make sure things work.
Regards
Ralph
1. in this case as 'rewrites' files can be specified as includes vhost configuration files:
2. While converting from AMS to AEM cloud dispatcher, it is mentioned to "Remove allowlists"
- Remove the folder conf.d/whitelists and remove Include statements in the virtual host files referring to
some file in that subfolder.
3. You can refer/ use Dispatcher Converter Tool if trying to migrate from AMS dispatcher configs to AEM cloud:
Hi,
Can you check if is works or not if you inlcude default file and custom file to rewrite.rules file
e.g.
https://github.com/arunpatidar02/aemaacs-aemlab/tree/master/dispatcher.cloud/src/conf.d/rewrites
Hi Arun,
The rewrite.rules and the default_rewrite.rules seems to work but why can't we have any other custom rewrite.rules file but as per the following attached pic from Adobe site it should technically work.
Also in my case i am having more than 400 rewrite rules so segregating them into domain wise different files would be kind of a better option to avoid mishaps.
Link to site - https://experienceleague.adobe.com/docs/experience-manager-cloud-service/implementing/content-delive...
Regards
Ralph
Hi,
According to the troubleshooting docs, the custom rewrite rules can be added into rewrite.rule and defualt_rewrite.rule is optional to add.
There are two types of files in your Apache virtual host configuration that can be specified as includes: rewrites and variables. The included files need to be named as follows:
Type Include file name
Rewrites | conf.d/rewrites/rewrite.rules |
Variables | conf.d/variables/custom.vars |
Alternatively, you can include the default version of the rewrite rules, whose name is conf.d/rewrites/default_rewrite.rules. Note, that there is no default version of the variables files.
And as you already mentioned that the new flexible mode does not have this limitation, did you tried with new Flexible mode
Flexible mode - the recommended mode, and the default for AEM archetype 28 and higher, which is also used by Cloud Manager for new environments created after the Cloud Manager 2021.7.0 release. Customers can activate this mode by adding the folder and file opt-in/USE_SOURCES_DIRECTLY. By using this more flexible mode, there are no limitations in the file structure under the rewrites folder that in legacy mode required a single rewrite.rules file. Also, there is no limitation on the number of rules you can add. For for details on folder structure and local validation see Validating and Debugging using Dispatcher Tools.
Legacy mode - for details on the folder structure and local validation for dispatcher configuration legacy mode, see Validating and Debugging using Dispatcher Tools (Legacy)
rm -rf ./out && ./bin/validator full -relaxed ./src
i had tried and it didnt work, even Adobe support guys mentioned that the feature doesnt work.
Not sure why its advertised if its not supported.
@Ralph8 - I am facing the same issue, even with opt-in/USE_SOURCES_DIRECTLY in the repo (archetype 35), I am still not able to add separate rewrite rule files for each site.
Is there no fix for this problem yet ?
Hi Arun,
My project archetype is 35 and by default has the opt-in folder with USE_SOURCES_DIRECTLY file present.
However, even then I am getting the same error.
If I run the validator in relaxed mode as suggested, its working fine -
C:\Users\rohan.garg\aem-sdk\dispatcher\aem-sdk-dispatcher-tools-2.0.91-windows\bin>validator full -relaxed D:/DestPet/Branches/Dispatcher_New/aemrepo/dispatcher/src
Cloud manager validator 2.0.34
2022/08/02 13:14:31 No issues found
However in non-relaxed mode, it throws the below message -
C:\Users\rohan.garg\aem-sdk\dispatcher\aem-sdk-dispatcher-tools-2.0.91-windows\bin>validator.exe full -d ../out D:/DestPet/Branches/Dispatcher_New/aemrepo/dispatcher/src
Cloud manager validator 2.0.34
2022/08/02 13:14:37 conf.d\rewrites\rewrite.rules:9: included file (conf.d\rewrites\abc_rewrite.rules) does not match any known fileconf.d\rewrites\rewrite.rules:9: included file (conf.d\rewrites\abc_rewrite.rules) does not match any known file
However, on the cloud the redirections didn't work as intended for the different "abc" site.
Update - the redirections are working correctly now, I just arranged the sequence of redirects to make them more coherent. The problem is not replicable for me anymore.
The multiple rewrites call works in flexible mode.
HI @Rohan_Garg
I am not sure if flexible mode works or not, I will try and let you know
@arunpatidar - I am able to add multiple rewrite files from rewrite.rules file.
However, I want to separate them based on domain.
Include conf.d/rewrites/default_rewrite.rules
Include conf.d/rewrites/xyz_rewrite.rules
Is there any way to conditionally filter the include file based on domain ?
I tried to use the below -
<If "%{HTTP_HOST} == 'xyzdomain.com'">
Include conf.d/rewrites/xyz_rewrite.rules
</If>
But got the below error -
AH00526: Syntax error on line 11 of /etc/httpd/conf.d/rewrites/xyz_rewrite.rules:
<LocationMatch not allowed in <If> context
Hi @Rohan_Garg ,
Did you get any solution for the issue ?
I also have the requirement of rewrite rules based on different domain but multiple rewrite files are not working.
So , I added rules in domain's vhost file under <IfModule mod_rewrite.c> but this is also not working.
Views
Replies
Total Likes
you can use environmental variables in the Dispatcher files if domains are different for environments
Views
Replies
Total Likes
Hello, I have a similar issue on my local environment.
I'm using flex mode for my dispatcher configs in the AEM cloud, and when I try to add a custom folder to conf.d/rewrites,
e.g
(conf.d/rewrites/CUSTOM_FOLDER_A/CUSTOM_REWRITE_FOR_A.rules)
(conf.d/rewrites/CUSTOM_FOLDER_B/CUSTOM_REWRITE_FOR_B.rules)
I see the following error while executing in the console.
"cp: can'tcreate CUSTOM_FOLDER/CUSTOM_REWRITE.rules"
But when I add CUSTOM_REWRITE.rules right under conf.d/rewrites/ it works
The problem only with additional folders under rewrites directory
Do u have any idea how can I resolve this issue?
Views
Replies
Total Likes
Views
Likes
Replies
Views
Likes
Replies