最简单的.htaccess重定向的index.php / html和非www到www根最简单、重定向、htaccess、index

2023-09-02 20:40:41 作者:拖拉机再垃圾也能拖垃圾

什么是重定向的index.php,index.html,然后非www变种到www根目录的.htaccess最简单的方法是什么?例如重定向

  http://example.com/index.php
http://www.example.com/index.html
http://example.com
 

要 http://www.example.com ?

解决方案

 的RewriteCond%{HTTP_HOST} ^例如 .COM [NC]
重写规则^(。*)$ http://www.example.com/$1 [L,R = 301]
 

rewirte伪静态的虚拟主机是否支持301重定向 也就是是否支持.htaccess文件

What is the simplest way to redirect index.php, index.html and non-www variants to the www root with .htaccess? For example redirecting

http://example.com/index.php
http://www.example.com/index.html
http://example.com

to http://www.example.com?

解决方案

RewriteCond %{HTTP_HOST} ^example.com [NC]
RewriteRule ^(.*)$ http://www.example.com/$1 [L,R=301]