如何使.htaccess将所有链接重定向到.html后缀

时间:2012-12-21 12:34:54

标签: .htaccess

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

如何将htaccess重定向.php或seo链接(不带扩展名)转换为.html

如何使用rewriteCond和rewriteRule或redirectmatch

制作它

1 个答案:

答案 0 :(得分:0)

这将有效

# 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