Rewrite url not working for html extension in source url.

Avatar

Avatar
Give Back
Level 2
shivama92274331
Level 2

Likes

4 likes

Total Posts

18 posts

Correct reply

2 solutions
Top badges earned
Give Back
Boost 3
Boost 1
Affirm 1
View profile

Avatar
Give Back
Level 2
shivama92274331
Level 2

Likes

4 likes

Total Posts

18 posts

Correct reply

2 solutions
Top badges earned
Give Back
Boost 3
Boost 1
Affirm 1
View profile
shivama92274331
Level 2

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
Boost 5
Level 2
lucian_nicolaescu
Level 2

Likes

8 likes

Total Posts

7 posts

Correct reply

3 solutions
Top badges earned
Boost 5
Boost 3
Boost 1
Affirm 3
Affirm 1
View profile

Avatar
Boost 5
Level 2
lucian_nicolaescu
Level 2

Likes

8 likes

Total Posts

7 posts

Correct reply

3 solutions
Top badges earned
Boost 5
Boost 3
Boost 1
Affirm 3
Affirm 1
View profile
lucian_nicolaescu
Level 2

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
Establish
MVP
BrianKasingli
MVP

Likes

645 likes

Total Posts

607 posts

Correct reply

239 solutions
Top badges earned
Establish
Ignite 1
Give Back 5
Give Back 3
Give Back 10
View profile

Avatar
Establish
MVP
BrianKasingli
MVP

Likes

645 likes

Total Posts

607 posts

Correct reply

239 solutions
Top badges earned
Establish
Ignite 1
Give Back 5
Give Back 3
Give Back 10
View profile
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
Applaud 25
Level 10
asutosh_jena
Level 10

Likes

593 likes

Total Posts

705 posts

Correct reply

207 solutions
Top badges earned
Applaud 25
Give Back 100
Boost 500
Affirm 100
Ignite 1
View profile

Avatar
Applaud 25
Level 10
asutosh_jena
Level 10

Likes

593 likes

Total Posts

705 posts

Correct reply

207 solutions
Top badges earned
Applaud 25
Give Back 100
Boost 500
Affirm 100
Ignite 1
View profile
asutosh_jena
Level 10

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.