【问题标题】:My htaccess is not working in 000webhost我的 htaccess 在 000webhost 中不起作用
【发布时间】:2016-02-22 12:08:04
【问题描述】:
RewriteEngine on
RewriteBase /
RewriteCond $1 !^(index\.php|assets|woff|eot|img|css|js|resources|robots\.txt)   
RewriteRule ^(.*)$ index.php/$1 [L]

这是我在 000webhost 上与 Codeigniter 一起使用的 .htaccess 文件,它运行良好。

我现在已经更新了每个文件,但相同的 .htaccess 无法正常工作。

我现在收到“500 内部服务器错误”。 可能是什么问题?

我的网址是futsal-groove.net16.net/home

【问题讨论】:

  • 尝试删除您的.htaccess然后尝试访问您的应用程序。
  • 你在htaccess中还有其他规则吗?
  • 删除 htaccess 会出现 404 错误。并且没有其他规则..
  • 你用的是什么版本的codeigniter?
  • 检查:确保您使用 CI3 检查文件名和类名的首字母大写。

标签: php .htaccess codeigniter


【解决方案1】:

某些安装需要不同的方法来解决此问题。它可以是 PHP 版本、apache 版本或其他版本。在某些 php 安装中,需要在 index.php 之后的 .htaccess 文件中添加问号 尝试以下解决方案:

# Turn on URL rewriting
RewriteEngine On

# Installation directory
RewriteBase /
# If fuel is not a level up
# RewriteBase /public

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

RewriteRule ^(.*)$ index.php?/$1 [L]
# Notice the ? after index.php

RewriteRule ^(.*)$ index.php?$1 [L]
# Notice the fact that the slash has been removed after the ?

#Other possible setups:

RewriteRule ^(.*)$ /index.php/$1 [L]
# Notice the leading slash added before index.php

找到它here

【讨论】:

    【解决方案2】:

    使用这个

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

    CodeIgniter URLs .htaccess in codeigniter.com

    【讨论】:

      【解决方案3】:

      试试这个

       RewriteEngine On
       RewriteCond %{REQUEST_URI} ^/system.*
       RewriteRule ^(.*)$ index.php?/$1 [L]
       RewriteCond %{REQUEST_FILENAME} !-f
       RewriteCond %{REQUEST_FILENAME} !-d
       RewriteRule ^(.+)$ index.php?/$1 [L]
      

      【讨论】:

      • @Nabin 你什么时候得到 404??
      【解决方案4】:

      htaccess文件应该放在主目录

      application
      system
      .htaccess
      index.php
      

      试试这个代码

      Options +FollowSymLinks
      Options -Indexes
      DirectoryIndex index.php
      RewriteEngine on
      RewriteCond $1 !^(index\.php|images|robots\.txt)
      RewriteCond %{REQUEST_FILENAME} !-f
      RewriteCond %{REQUEST_FILENAME} !-d
      RewriteRule ^(.*)$ index.php/$1 [L,QSA]
      

      在你的配置文件中

      $config['base_url'] = 'http://www.example.com/';
      $config['index_page'] = '';
      

      【讨论】:

      • 也没有工作。我现在很困惑它的 htaccess 文件是否引发了这个错误。还有什么可能会出现这个问题?
      【解决方案5】:

      用这个更改你的 htaccess 代码

      RewriteEngine On
      RewriteBase /
      
      RewriteCond %{REQUEST_URI} ^system.*
      RewriteCond $1 !^(index\.php|images|js|uploads|css|robots\.txt)
      RewriteRule ^(.*)$ /index.php/$1 [L]
      RewriteCond %{REQUEST_FILENAME} !-f
      RewriteCond %{REQUEST_FILENAME} !-d
      RewriteRule ^(.*)$ index.php?/$1 [L,QSA]
      

      【讨论】:

        【解决方案6】:

        尝试使用 RewriteBase 指令或在重写目标中使用绝对路径

        RewriteEngine On
        
        
        RewriteBase /
        RewriteCond %{REQUEST_FILENAME} !-f
        RewriteCond %{REQUEST_FILENAME} !-d
        RewriteRule ^(.*)$ index.php/$1 [NC,L]
        

        注意:000webhost 服务器使用虚拟用户主目录,因此在 Rewrite 目标中使用相对路径时添加 RewriteBase 指令很重要,否则会出现 404 未找到。

        来源:

        https://www.000webhost.com/faq.php?ID=16

        【讨论】:

          猜你喜欢
          • 1970-01-01
          • 1970-01-01
          • 2012-03-20
          • 1970-01-01
          • 2015-09-25
          • 1970-01-01
          • 1970-01-01
          • 2013-01-20
          • 2017-07-27
          相关资源
          最近更新 更多