簡體   English   中英

如何讓.htaccess重定向所有鏈接到.html后綴

[英]How to make .htaccess redirect all links to .html suffix

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

如何使.htaccess 重定向.php,或seo 鏈接(無擴展名)到.html

如何使用 rewriteCond 和 rewriteRule 或 redirectmatch 來實現

這會起作用

# 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

在這一行:

RewriteRule ^(.*)\.html$ $1.php [L]

您更改了 php/html 的順序。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM