How to make .htaccess redirect all links to .html

2019-09-05 09:15发布

http://advokat-malov.ru/index.php
http://advokat-malov.ru/ 
http://advokat-malov.ru/index.html

how to make htaccess redirect .php, or seo links(without extension) to .html

how to make it using rewriteCond and rewriteRule or redirectmatch

标签: .htaccess
1条回答
够拽才男人
2楼-- · 2019-09-05 09:22

This will work

# This will change all .php to .html
RewriteEngine on
RewriteBase /
RewriteRule ^(.*)\.html$ $1.php [L]


# This will add .html to all urls that are not in the white list
# White list extensions php, html, css, js, less, jpg, png, gif
RewriteEngine On
RewriteCond %{REQUEST_URI} !\.(php|html|css|js|less|jpg|png|gif)$
RewriteCond %{REQUEST_URI} !/$
RewriteRule ^(.*)$ $1.html
查看更多
登录 后发表回答