Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
Bedrock Mission!

Learn more

View all

Sign in to view all badges

SOLVED

Rewrite url not working for html extension in source url.

shivama92274331
Level 2
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
lucian_nicolaescu
Correct answer by
Level 2
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
lucian_nicolaescu
Correct answer by
Level 2
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

shivama92274331
Level 2
Level 2
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.
Asutosh_Jena_
Community Advisor
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.

BrianKasingli
Community Advisor
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]
shivama92274331
Level 2
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.