Rewrite url not working for html extension in source url.

Avatar

Avatar

shivama92274331

Avatar

shivama92274331

shivama92274331

04-02-2021

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

Accepted Solutions (1)

Accepted Solutions (1)

Avatar

Avatar

lucian_nicolaescu

Avatar

lucian_nicolaescu

lucian_nicolaescu

04-02-2021

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.

Answers (2)

Answers (2)

Avatar

Avatar

BrianKasingli

MVP

Avatar

BrianKasingli

MVP

BrianKasingli
MVP

04-02-2021

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

Avatar

asutosh_j3

Avatar

asutosh_j3

asutosh_j3

04-02-2021

@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.