HTACCESS - Replace everything ending html with a t

2019-09-21 17:47发布

I am trying to replace everything ending with the extension html (.html) with a trailing (\) slash i.e.

http://www.example.com/ibizaparty.html to http://www.example.com/ibizaparty/

How can this be resolved using .htaccess i.e. redirect/rewrite rules?

Your help is greatly appreciated?

1条回答
beautiful°
2楼-- · 2019-09-21 18:29

I'm giving you the code but for future questions please look around and search the site before you just make a question that has been answered millions of times.

RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}\.html -f
RewriteRule ^([^/]+)/$ $1.html 

# Forces a trailing slash to be added
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !(\.[a-zA-Z0-9]{1,5}|/)$
RewriteRule (.*)$ /$1/ [R=301,L]
查看更多
登录 后发表回答