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.
-
Hi I have to remove trailing slash for cms page can U advise me how to do it?Nagaraju Kasa– Nagaraju Kasa2020年08月21日 02:44:34 +00:00Commented Aug 21, 2020 at 2:44
4 Answers 4
Magento admin you can use store direct_url for remove trailing slash.
example:
<a href="{{store direct_url='contact-us'}}">Contact</a>
-
Hi @savan patel i have tried this but no luck. Can you advise me alternative wayNagaraju Kasa– Nagaraju Kasa2020年08月21日 02:43:11 +00:00Commented Aug 21, 2020 at 2:43
-
Hello @NagarajuK Please try to do re-indexing and clean & flush Magento Cache and Browser Cache and check againSavan Patel– Savan Patel2020年08月21日 05:39:26 +00:00Commented Aug 21, 2020 at 5:39
ADD this code so trailing slash remove
$hreflangUrl= https://www.example.com/contactus.html/ $result = rtrim($hreflangUrl, "/"); $result=https://www.example.com/contactus.html
Add below code in the end of your root's .htaccess file -
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)/$ /1ドル [L,R] #
-
1I have tried the redirect code as per your suggestion. But it leads to infinite redirect loop. Any other solution?Intellect Outsource– Intellect Outsource2018年06月25日 05:05:14 +00:00Commented Jun 25, 2018 at 5:05
-
This will cause redirect loop on admin panelAndy– Andy2022年12月01日 14:36:51 +00:00Commented Dec 1, 2022 at 14:36
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
Explore related questions
See similar questions with these tags.