Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/.htaccess/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
.htaccess htaccess如何立即重定向到home.php?_.htaccess_Indexing - Fatal编程技术网

.htaccess htaccess如何立即重定向到home.php?

.htaccess htaccess如何立即重定向到home.php?,.htaccess,indexing,.htaccess,Indexing,我用下面的代码“DirectoryIndex home.php”将index.php改为home.php。 现在我希望,当人们访问我的网站时,它会立即转到www.mywebsite.com/home.php,而不仅仅是www.mywebsite.com 这可能吗? 我试着用谷歌搜索,但找不到我要找的东西 我希望这能解释我的问题。 我的英语不是很好,所以我尽我所能把它解释得尽可能好 您只需添加此规则即可将/index.php重定向到/home.php RewriteEngine on Rewrit

我用下面的代码“DirectoryIndex home.php”将index.php改为home.php。 现在我希望,当人们访问我的网站时,它会立即转到www.mywebsite.com/home.php,而不仅仅是www.mywebsite.com

这可能吗? 我试着用谷歌搜索,但找不到我要找的东西

我希望这能解释我的问题。
我的英语不是很好,所以我尽我所能把它解释得尽可能好

您只需添加此规则即可将
/index.php
重定向到
/home.php

RewriteEngine on
RewriteRule ^index\.php$ /home.php [R=301,L]

确保启用了
mod_rewrite

另一个否定重定向的选项是设置
DirectoryIndex
指令
DirectoryIndex home.php

RewriteEngine on
RewriteRule ^index\.php$ /home.php [R=301,L]

当人们访问您的域时,这不会导致重定向,但是如果他们键入index.php,您仍然需要在另一个答案中发布重写内容。

或者您可以创建一个
index.php
,并将以下代码放入其中:

<?php header("Location: /home.php"); ?>

你为什么要将index.php命名为home.php呢?不管怎样,它是每个网站的根文件和登录页面,而且它们都是SEO友好型的,所以在这方面没有太多的改进。