skip to Main Content

How do I redirect from .html/ to .html ?

I redirected my old Blog Directory to the News Directory but it does it with a Slash at the end after .html

I tried those two lines in my .htaccess file but it did nothing…

RewriteRule (.*.html)/$ $1 [R=301,L]

RewriteRule (.*.html)/$ $1 [R,L]

2

Answers


  1. Chosen as BEST ANSWER

    I found the answer to my problem:

    You need this below your RewriteEngine on

    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.*)/$ /$1 [L,R] # <- for test, for prod use [L,R=301]
    

  2. You need this below your RewriteEngine on

    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.*)/$ /$1 [L,R] # <- for test, for prod use [L,R=301]
    

    or

    RewriteRule .*.html/$ $1 [R=301,L]
    

    or

     RewriteRule (.*).html/$ http://www.example.com$1.html [R=301,L]
    

    or

    RewriteRule ^(.+).html/$ $1.html [R=301,L]
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search