重定向的index.php根和WWW非WWW与rewrite_mod [英] Redirect index.php to root, and www to non www with rewrite_mod
本文介绍了重定向的index.php根和WWW非WWW与rewrite_mod的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
有人知道要如何把这个规则娄的.htaccess?
someone knows how can i redirect in the .htaccess this rules bellow ?
http://www.domain.com/index.php to http://domain.com
和
http://www.domain.com to http://domain.com
许多坦克
推荐答案
由于我猜的index.php
是当你去你的文档根目录得到什么服务,要明确检查的index.php
是什么东西是要求和URI,这将是一次URL不属于 - 文件映射管道做它的事。
Since I'm guessing index.php
is what gets served when you go to your document root, you want to explicitly check that /index.php
is what is being requested, and not part of the URI, which it will be once the URL-file mapping pipeline does its thing.
RewriteEngine On
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /index\.php
RewriteRule ^index\.php$ / [L,R=301]
然后WWW到非www:
Then the www to non-www:
RewriteCond %{HTTP_HOST} ^www\.domain\.com$ [NC]
RewriteRule ^(.*)$ http://domain.com/$1 [L,R=301]
这篇关于重定向的index.php根和WWW非WWW与rewrite_mod的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文