【问题标题】:FollowSymlinks .htaccess Rewrite Rule 404 ErrorFollowSymlinks .htaccess 重写规则 404 错误
【发布时间】:2013-06-28 07:11:46
【问题描述】:

我的真实网址是:

www.mysite.com/site/index.php

我需要:

www.mysite.com/home.html

我在.htaccess中写:

  Options +FollowSymlinks
  RewriteEngine On
  RewriteRule (.*)/home.html$ /site/index.php

但是转到 404 错误

有什么帮助吗?

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>

但没有工作。

【问题讨论】:

    标签: .htaccess mod-rewrite http-status-code-404


    【解决方案1】:

    RewriteRule 指令的 pattern 部分与请求的 path 匹配(例如 /my/request/),主机和查询字符串不匹配包括。另请注意,在 .htaccess 上下文中,前导斜杠不包含在 pattern 中。

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

    【讨论】:

    • 我对此进行了更改: Options +FollowSymlinks RewriteEngine On RewriteBase / RewriteRule ^home\.html$ site/index.php 但没有工作文件 .htaccess 是保存在 www.mysite.com/site/
    【解决方案2】:

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

    AllowOverride NoneAllowOverride All

    然后工作吧!

    【讨论】:

      【解决方案3】:

      你在cmets中说:

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

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

      您应该将.htaccess 放在文档根目录中,并且如前所述,从模式中删除这部分:(.*)/

      【讨论】:

        【解决方案4】:

        本站由 godaddy.com 托管,服务器通过 IIS 在 Windows 中运行,因此,规则必须写在 web.config 文件中。

        <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>
        

        难以置信!!

        【讨论】:

          猜你喜欢
          • 2023-04-08
          • 2016-09-14
          • 1970-01-01
          • 2013-11-24
          • 2012-03-30
          • 1970-01-01
          • 2014-05-12
          • 2014-09-22
          相关资源
          最近更新 更多