最简单的.htaccess重定向的index.php / html和非www到www根 [英] Simplest Htaccess for Redirecting index.php/html and non-www To www Root

查看:139
本文介绍了最简单的.htaccess重定向的index.php / html和非www到www根的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

什么是重定向的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]
 

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]

这篇关于最简单的.htaccess重定向的index.php / html和非www到www根的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆