0

I have installed ssl in my Magento 2 store and configured base url to the https version.

But when accessing http version, Magento redirecting url with appending trailing slash.

For example:

My domain is example.com

Base url saved in configuration is https://www.example.com

When I accessing http version http://www.example.com/contactus.html

it is redirecting to https://www.example.com/contactus.html/

Could you please help to remove the trailing slash while redirecting.

1

Magento admin you can use store direct_url for remove trailing slash.

example:

<a href="{{store direct_url='contact-us'}}">Contact</a>
0

Add below code in the end of your root's .htaccess file -

RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)/$ /$1 [L,R] # 
  • I have tried the redirect code as per your suggestion. But it leads to infinite redirect loop. Any other solution? – Intellect Outsource Jun 25 '18 at 5:05
0

ADD this code so trailing slash remove

$hreflangUrl= https://www.example.com/contactus.html/ $result = rtrim($hreflangUrl, "/"); $result=https://www.example.com/contactus.html

0

You can intercept base magento 2 methods to rtrim the trailing slash. But it could lead to errors. Here is the example: https://github.com/vsevolod-tarasov/links

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.