0

We have some wrong URLs in our store ending with .html. If the user opens such a URL, then the .html should get removed, otherwise the site cant get found.

So I added this rule to my .htaccess file in pub/.htaccess, i also tried the normal .htaccess in the magento root.

<IfModule mod_rewrite.c>

...

############################################
## Remove .html from end of URL

    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME} !-l
    RewriteRule ^(.*)\.html$ /$1 [L,R=302]

</IfModule>

But if I enter a URL with .html at the end, then it is still not getting removed.

I want to make it work by using the .htaccess, otherwise I will have to create plenty of URL rewrites by hand.

2
  • Why you not using Magento 2 default configuration for this..? Dec 1 '20 at 16:03
  • What do you mean exactly?
    – Black
    Dec 2 '20 at 8:23
0

Hi I understand actually you want to redirect .html page to without.html page

You can add following code in .htaccess : for example :

Redirect /specific-page.html /specific-page 
2
  • Yes, but I dont want to redirect a single page, I want to redirect ALL URLs.
    – Black
    Dec 2 '20 at 8:24
  • Try this : RedirectMatch (.*)\.html$ http:// example.com$1 Dec 3 '20 at 17:19

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.