【问题标题】:I am getting 500 internal server error htaccess我收到 500 个内部服务器错误 htaccess
【发布时间】:2017-03-20 19:32:47
【问题描述】:

我是 MVC 新手(刚刚学习),我正在学习本教程: https://www.youtube.com/watch?v=xYxw7-zQaV8&list=PLU6gyrizgE6rTrd5K-U94UryjYIQ1GfDd&index=3

我正在使用 MAMP

我的根目录是 MAMP/htdocs/

我的 mvc 项目在 MAMP/htdocs/MVC 中

我的一个 htaccess 文件位于 MAMP/htdocs/MVC - 它将请求重定向到 .../MVC/webroot

我在 MVC 文件夹中的 htaccess 文件如下:

#开启引擎 重写引擎开启

RewriteRule ^$ webroot [L]
RewriteRule (.*) webroot/$1  [L]

我在webroot目录下的另外一个htaccess文件如下:

重写引擎开启

RewriteCond % [REQUEST_FILENAME] !-f  
RewriteCond % [REQUEST_FILENAME] !-d    


RewriteRule ^{.*}$  index.php [PT,L]

请帮助我缓解压力。我想学习这个,从下午开始就被困住了。

【问题讨论】:

  • 当您收到 500 错误时,请检查您的服务器错误日志。检查 MAMP 以找出它的存储位置。 500 错误本身就太宽泛了,可以是任意数量的东西。
  • 你确定是.htaccess 文件问题吗?另外,你是用mac还是windows?
  • 很抱歉告诉你这个,但是那个教程与 MVC 无关。

标签: php .htaccess


【解决方案1】:

我用 linter 快速查看了您的 htaccess(我使用了 http://www.htaccesscheck.com/ ):

RewriteCond % [REQUEST_FILENAME] !-f  
RewriteCond % [REQUEST_FILENAME] !-d    

这似乎是错误的! 试试这个语法:

RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d

(注意{ 与您的[ )

【讨论】:

    【解决方案2】:
    <IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /MVC/
    RewriteRule ^index\.php$ - [L]
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule . /MVC/webroot/index.php [L]
    </IfModule>
    

    IfModule 标记是为了确保启用了重写模块,这样你就不会遇到 htaccess 错误。

    【讨论】:

      猜你喜欢
      • 2016-09-22
      • 2017-04-05
      • 1970-01-01
      • 2013-02-06
      • 2015-06-28
      • 2016-04-20
      • 1970-01-01
      • 2014-01-01
      相关资源
      最近更新 更多