Expand my Community achievements bar.

Learn about Edge Delivery Services in upcoming GEM session
SOLVED

Rewrite url not working for html extension in source url.

Avatar

Level 2

Hi,

The rewrite rules are not working for having source url's extension as html, they are not redirecting to the destination url on browser and source url remains same, for example below redirects don't work while other redirects having no extension or other extension are working fine. Any leads?

 

1. RewriteRule ^/applications/life-science-research.html  /en/products-solutions/all-application.html [R=301,L,NC]
2. RewriteRule ^/applications/life-science-research/dna-sequencing.html  /en/products-solutions/all-application.html [R=301,L,NC]
3. RewriteRule ^/products/assays.html  /en/products-solutions/by-category/assays.html [R=301,L,NC]

 

Regards,

Shivam

1 Accepted Solution

Avatar

Correct answer by
Level 2

The rules should work, you need to pay attention to the order of the RewriteRules.

For example, if you have another rewrite rule that adds the "long" URL (will transform /applications/life-scrience-research.html -> /content/yoursite/en/applications...), this rule will not match because of that ^ meaning that's the start of the string.

 

PS: You should add "LogLevel debug rewrite:trace6" and you will see the "order" and matching of your rules in the logs.

View solution in original post

5 Replies

Avatar

Correct answer by
Level 2

The rules should work, you need to pay attention to the order of the RewriteRules.

For example, if you have another rewrite rule that adds the "long" URL (will transform /applications/life-scrience-research.html -> /content/yoursite/en/applications...), this rule will not match because of that ^ meaning that's the start of the string.

 

PS: You should add "LogLevel debug rewrite:trace6" and you will see the "order" and matching of your rules in the logs.

Hi lucian_nicolaescu, i agree with you order of rewrite rules matter, but in this case the rewrite urls were working with same order. Recently in past we have done migration of our dispatcher setup to newer one 4.1.9 after this it seems to have issue.

Avatar

Community Advisor

@shivama92274331 You can check what is the request URL that is being sent in the dispatcher.log as well as in the publish instance request.log. There might be some rules that are added which are causing the issue and it's not allowing to redirect with .html extension.

Looking into the dispatcher log and request.log will give more idea on the issue.

Avatar

Community Advisor

Can you share with us your entire file please, you might have some other rewrites before these 3 rules. That might be the causing problem.

 

From what I am seeing, your redirect rule looks fine. 

 

Also make sure you add $ to indicate that this is the end of the pattern.

RewriteRule ^/applications/life-science-research.html$ /en/products-solutions/all-application.html [R=301,L,NC]

Avatar

Level 2
Hi @BrianKasingli, the 3 urls shared here are one of the rewrite url set which is not working, all the rewrite urls having .html as extension is not working.