Add trailing slash after removing .html extention

My website is non www ,it has wordpress in subdirectory and some static webpages in the root and other subdirectory

  1. i want to remove .html extention from the webpages in the root and
    the others static webpages in subdirectory.
  2. add slash at the end.
  3. 301 redirect from non slash to url with slash.

so it should be

/articles.html to /articles/


/en/poem-list.html to /en/poem-list/

the below code

  1. working with non slash at the end
  2. redirect 301 url with slash to non
  3. doesn’t work with static webpages in subdirectory

here’s my .htaccess

    <IfModule mod_rewrite.c> 
    Options +FollowSymLinks -MultiViews

    RewriteEngine On 
    RewriteBase /

   #removing trailing slash
   RewriteCond %{REQUEST_FILENAME} !-d     
   RewriteRule ^(.*)/$ $1 [R=301,L]

    #www to non
    RewriteCond %{HTTP_HOST} ^www\.(([a-z0-9_]+\.)?domain\.com)$ [NC]
    RewriteRule .? http://%1%{REQUEST_URI} [R=301,L]

    RewriteCond %{REQUEST_FILENAME} !-f 
    RewriteCond %{REQUEST_FILENAME} !-d 
    RewriteRule ^([^\.]+)$ $1.html [NC,L]

    #index redirect 
    RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /index\.html\ HTTP/ 
    RewriteRule ^index\.html$ [R=301,L]
    RewriteCond %{THE_REQUEST} \.html 
    RewriteRule ^(.*)\.html$ /$1 [R=301,L] 

PS everything is ok with the wordpress , the problems with static pages only.

Thanks in advanced

I’m sorry, this is a Kirby forum, we do not deal with Wordpress here.

1 Like