.htaccess 空时重定向到主页

.htaccess 空时重定向到主页,.htaccess,redirect,.htaccess,Redirect,我的页面正常工作,但当我遇到如下情况时: www.mysite.com www.misite.com/ www.miste.com/index.php 我需要它重定向到www.mysite.com/home/(并将其显示给用户) 我可以用.htaccess来做吗 我的.htaccess文件: RewriteEngine On Options +FollowSymLinks RewriteCond %{HTTP_HOST} !^www [NC] RewriteRule ^(.*)$ http:

我的页面正常工作,但当我遇到如下情况时:

www.mysite.com
www.misite.com/
www.miste.com/index.php
我需要它重定向到www.mysite.com/home/(并将其显示给用户)

我可以用.htaccess来做吗

我的.htaccess文件:

RewriteEngine On
Options +FollowSymLinks

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

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_URI} !index.php
RewriteCond %{REQUEST_URI} !(.*)/$
RewriteRule ^(.*)$ http://%{HTTP_HOST}/$1/ [L,R=301]

RewriteCond %{SCRIPT_FILENAME} !-f
RewriteCond %{SCRIPT_FILENAME} !-d
RewriteRule ^(.*)$ index.php?par=$1

ErrorDocument 404 index.php

假设您的问题中没有拼写错误:

www.mysite.com
www.misite.com/
www.miste.com/index.php
这三个域都指向同一个文档根。你想要这样的东西:

RewriteCond {HTTP_HOST} ^(www\.)?(mysite|misite|miste)\.com$ [NC]
RewriteRule ^(index\.php)?$ http://www.mysite.com/home/ [L,R=301]