重写404错误规则



我的真实网址是:

www.mysite.com/site/index.php

我需要

:

www.mysite.com/home.html

我在。htaccess中写:
  Options +FollowSymlinks
  RewriteEngine On
  RewriteRule (.*)/home.html$ /site/index.php

但是转到404 Error

帮忙吗?

Tk。更新:

有任何影响,域名实际上是:www.my-site.com ??

更新:

我保存在www.my-site.com并更改为:

<IfModule mod_rewrite.c>
  Options +FollowSymlinks
  RewriteEngine On
  RewriteBase /
  RewriteRule ^home.html$ site/index.php
</IfModule>

rewriterrule指令的模式部分匹配请求的路径。/my/request/),则不包含主机和查询字符串。还要注意,在中。模式中不包含前导斜杠。

  Options +FollowSymlinks
  RewriteEngine On
  RewriteBase /
  RewriteRule ^home.html$ site/index.php

在我的服务器,我改变了在Apache的httpd.conf

AllowOverride NoneAllowOverride All

And Work it!

您在评论中说:

.htaccess文件保存在www.mysite.com/site/

这意味着,使用当前模式,您可以访问www.mysite.com/site/anything/home.html, CC_4将被重写为www.mysite.com/site/site/index.php

您应该将.htaccess放在文档根目录中,并且,正如已经建议的那样,从模式中删除这部分:

这个网站是由godaddy.com托管的,服务器运行在Windows上的IIS,所以,规则必须写在网页上。配置文件。

<configuration>
 <system.webServer>
   <rewrite>
  <rules>
    <rule name="Imported Rule 1">
      <match url="^home.html$" ignoreCase="false" />
      <action type="Rewrite" url="site/index.php" />
    </rule>
  </rules>
</rewrite>
 </system.webServer>
</configuration>

难以置信! !

最新更新