【问题标题】:Htaccess misconfiguration error 500Htaccess 错误配置错误 500
【发布时间】:2017-06-28 15:55:27
【问题描述】:

我在http://www.ssdpsjal.tk 实现了一个新的.htaccess 文件 我的代码是 -

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ n/index.php/$1 [L]
RewriteRule ^$ /index [L]
Redirect /administrator /sadmin1

我使用 CodeIgniter。您可以访问该网站查看错误。

此外,我已经在我的本地服务器上尝试过这个 .htacccess 并且它没有显示任何此类错误(我认为)

我的文档结构如下

--- ssdpsjal.tk                //given by host. Non-writable
  --n                          //the folder where website is stored
  --web_based_editor           //something my website uses
  --.htaccess file             //Htaccess file that I told about
  --Some other stuff not relevent to the question

编辑

我已经多次更改代码,经过一些更改后,我发现错误发生在RewriteRule ^(.*)$ n/index.php/$1 [L]

注意

RewriteRule ^$ /index [L] 处的index 不是Index.php 它实际上是我的codeigniter 控制器的一个函数(方法)

没有 .htaccess 的实际 URL 是 http://www.ssdpsjal.tk/n/index.php/s/index

注意句末的index,就是那个!

【问题讨论】:

  • 你的error.log 说什么?
  • 我看不到错误日志,因为主机服务提供商不允许我这样做。 (我是免费用户:()
  • RewriteRule ^(.*)$ n/index.php/$1 [L] 为什么是这个 n/ ?你只是想绕过显示index.php吗?
  • 其实n 是我存放网站的文件夹名称!我正在尝试从我的网站 URL 中隐藏 /n/index.php

标签: php .htaccess codeigniter codeigniter-3 http-status-code-500


【解决方案1】:

找到我自己问题的答案。

.htaccess 文件完全正确。问题出在虚拟主机上。他们在没有任何警告的情况下更新服务(通知在 5-6 小时后发出),因此许多服务被关闭。

嗯,我把我的虚拟主机换成了一个更好的新主机。 (000WebHost)

【讨论】:

    【解决方案2】:

    我不确定你的配置,但你确定 mod_rewrite 存在吗?

    也许:

    <IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule (.*)  http://www.ssdpsjal.tk/$1 [R=301,L]
    RewriteRule ^$ n/index.php [L]
    Redirect /administrator /sadmin1
    </IfModule>
    

    【讨论】:

    • 请看我刚刚插入的注释!任何帮助表示赞赏!
    • 是的,我确定 mod_rewrite 存在。
    • 它现在转到 URL http://www.ssdpsjal.tk/www.ssdpsjal.tk/n/index.php 并显示 Too many Redirects 错误
    【解决方案3】:
    <IfModule mod_rewrite.c>
      RewriteEngine On
      RewriteBase /
    
      RewriteRule ^administrator /sadmin1 [R=301,L]
    
      RewriteCond %{REQUEST_FILENAME} !-f
      RewriteCond %{REQUEST_FILENAME} !-d
      RewriteRule ^(.*)$ index.php?/$1 [L]
    </IfModule>
    

    或者只是改变这一行:

    RewriteRule ^(.*)$ n/index.php/$1 [L]
    

    进入:

    RewriteRule ^$ n/index.php [L]
    

    【讨论】:

    • 现在我收到 404 Not Found 错误
    • 在与 .htaccess 相同的文件夹中或在名为 'n' 的文件夹中?
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-10-01
    • 1970-01-01
    相关资源
    最近更新 更多