Php .htaccess该页面不是';不能正确地重定向

Php .htaccess该页面不是';不能正确地重定向,php,html,.htaccess,Php,Html,.htaccess,我试图将index.html重定向到home.html,并通过.htaccess从url中删除home.html。但它显示页面没有正确重定向。 这意味着我需要将mydomain.com/index.html重定向到mydomain.com/home.html,并且我只需要在访问索引页面时显示mydomain.com/ <IfModule mod_rewrite.c> RewriteEngine On RewriteBase / Redirect 301 "/index.html" "

我试图将index.html重定向到home.html,并通过.htaccess从url中删除home.html。但它显示页面没有正确重定向。 这意味着我需要将mydomain.com/index.html重定向到mydomain.com/home.html,并且我只需要在访问索引页面时显示mydomain.com/

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
Redirect 301 "/index.html" "/home.html"

RewriteCond %{THE_REQUEST} ^GET.*home\.html [NC]
RewriteRule (.*?)home\.html/*(.*) /$1$2 [R=301,NE,L]

</IfModule>

重新启动发动机
重写基/
重定向301“/index.html”“/home.html”
RewriteCond%{THE_REQUEST}^GET.*home\.html[NC]
重写规则(.*)home\.html/*(.*)/$1$2[R=301,NE,L]

您可以尝试将设置为所需页面(在您的例子中是home.html),而不是使用mod\u rewrite:

因此,如果您正在调用
domain.com/
它应该会提供
domain.com/home.html的内容

作为参考,Apache配置手册: “目录索引指令”


参考下面的对话:

也许这可以工作(对不起,我现在不能测试)

一点解释:如果请求的主机与example.com匹配,并且被调用的URI实际上不是真实的文件或文件夹,加上URI等于 “index.html”应该重定向到home.html


编辑:由于您不想显示home.html,我们可以通过在内部“代理”请求而不是强制执行外部重定向来逃避。尝试将最后一行(RewriteRule)中的“R=301”替换为“P”,这样它会显示
RewriteRule(.*)home\.html/*(.*)/$1$2[P,NE,L]

//这是工作代码,我希望它有用

<IfModule mod_rewrite.c>
RewriteEngine On
Redirect 301 / http://newsite.com/
</IfModule>

我还尝试了DirectoryIndex home.html,但它更改了目录中的所有index.html。我是说子域。因此,我只需要特定域。如果我理解正确,您只希望在特定域上发生这种情况,而不希望在该域的子域上发生这种情况?更新了我的回答,但显示了mydomain.com/home.html。但我只需要在URL中输入mydomain.com
RewriteCond %{HTTP_HOST} ^example\.com$ [NC]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} =/index.html
RewriteRule (.*?)home\.html/*(.*) /$1$2 [R=301,NE,L]
<IfModule mod_rewrite.c>
RewriteEngine On
Redirect 301 / http://newsite.com/
</IfModule>
RewriteEngine on
RewriteCond %{HTTP_HOST} ^(www\.)?http://dbdenterprise\.in$
RewriteRule ^(.*)$ http://dbdenterprise.com/$1 [R=301,QSA,L]