Doubt on Rewrite rules | Community
Skip to main content
Level 2
March 14, 2024
Solved

Doubt on Rewrite rules

  • March 14, 2024
  • 5 replies
  • 1057 views


Hi team,

May i know how to write a rewrite rule for

https://www.example.com/.testing-folder/sample-file.txt Internally it should hit /content/dam/testing-folder/sample-file.txt

 

I tried below but its not working

 

RewriteRule ^/.testing-folder/(.*)$ /content/dam/testing-folder/sample-file.txt [PT,L]

 

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 @shyams67489715 
Rules looks fine.
could you please check the url, it seems there is a . before the testing-folder in the rule.

5 replies

AMANATH_ULLAH
Community Advisor
Community Advisor
March 14, 2024

@shyams67489715 
Please try below rule

 

RewriteCond %{REQUEST_URI} ^/.testing-folder
RewriteRule ^/.testing-folder/(.*)$ /content/dam/testing-folder/$1 [PT,L]

Amanath Ullah
arunpatidar
Community Advisor
arunpatidarCommunity AdvisorAccepted solution
Community Advisor
March 14, 2024

Hi @shyams67489715 
Rules looks fine.
could you please check the url, it seems there is a . before the testing-folder in the rule.

Arun Patidar
Imran Khan
Community Advisor
Community Advisor
March 14, 2024

@shyams67489715 

Below will help to internal redirect:

Regex:

RewriteCond %{HTTP_HOST} https://www.example.com

RewriteRule ^/.testing-folder/(.*) /content/dam/testing-folder/sample-file.txt [PT,L] 

 

OR

 

Exact match

RewriteCond %{HTTP_HOST} https://www.example.com

RewriteRule ^/.testing-folder/sample-file.txt$

/content/dam/testing-folder/sample-file.txt

BrianKasingli
Community Advisor and Adobe Champion
Community Advisor and Adobe Champion
March 14, 2024

The rule looks okay, but id rather do (make sure you escape the DOT)

 

RewriteRule ^/\.testing-folder/sample-file\.txt$ /content/dam/testing-folder/sample-file.txt [PT,L]

 

https://www.example.com/.testing-folder/sample-file.txt 

kautuk_sahni
Community Manager
Community Manager
March 20, 2024

@shyams67489715 Did you find the suggestions from users helpful? Please let us know if more information is required. Otherwise, please mark the answer as correct for posterity. If you have found out solution yourself, please share it with the community.

Kautuk Sahni