【问题标题】:CodeIgniter .htaccess - 500 Internal Server Error/ index.php removeCodeIgniter .htaccess - 500 内部服务器错误/ index.php 删除
【发布时间】:2016-04-15 08:44:07
【问题描述】:

我有一个这样的网站(子域)

rabbani.websolocom.xyz

我有这样的.htaccess 代码(我使用了 Codeigniter):

RewriteEngine on
RewriteBase /rabbani
RewriteCond $1 !^(index\.php|resources|robots\.txt)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-D
RewriteRule ^(.*)$ index.php/$1 [L,QSA]

但是当我尝试访问我的网站时出现错误(500 内部服务器错误)。我应该如何处理我的.htaccess 文件?或者我的目录中有什么其他文件有问题?

【问题讨论】:

    标签: php apache .htaccess codeigniter mod-rewrite


    【解决方案1】:

    使用这个

    .htaccess(应用程序文件夹外)

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

    这是 Codeigniter 推荐的 .htaccess

    【讨论】:

      【解决方案2】:

      像这样将 .htaccess 放在 rabbani 文件夹中

      RewriteEngine on
      RewriteBase /
      RewriteCond %{REQUEST_URI} !\.[^./]+$
      RewriteCond %{REQUEST_URI} !(.*)/$
      

      【讨论】:

        【解决方案3】:

        试试这两个htaccess

        RewriteEngine on
        RewriteCond $1 !^(index\.php|resources|robots\.txt)
        RewriteCond %{REQUEST_FILENAME} !-f
        RewriteCond %{REQUEST_FILENAME} !-d
        RewriteRule ^(.*)$ /public_html/index.php/$1 [L,QSA]
        

        RewriteEngine on
        RewriteCond %{HTTP_HOST} ^(.*)\.domain\.com
        RewriteRule ^(.*)$ http://domain.com/%1/$1 [L,NC,QSA]
        

        更多htaccess here.

        【讨论】:

          【解决方案4】:

          这是我的新 .htaccess

          <IfModule mod_rewrite.c>
              RewriteEngine On
              # !IMPORTANT! Set your RewriteBase here and don't forget trailing and leading
              #  slashes.
              # If your page resides at
              #  http://www.example.com/mypage/test1
              # then use
              # RewriteBase /mypage/test1/
              RewriteBase /
              RewriteCond %{REQUEST_FILENAME} !-f
              RewriteCond %{REQUEST_FILENAME} !-d
              RewriteRule ^(.*)$ index.php?/$1 [L]
          </IfModule>
          

          【讨论】:

            【解决方案5】:

            试试这个: 如果您在本地系统上使用 codeigniter

            <IfModule mod_rewrite.c>
                RewriteEngine On
                RewriteBase /projectfolder/
                RewriteCond %{REQUEST_FILENAME} !-f
                RewriteCond %{REQUEST_FILENAME} !-d
                RewriteRule ^(.*)$ /projectfolder/index.php/$1 [L]
            </IfModule>
            

            如果你在服务器上使用它,那么使用这个:

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

            【讨论】:

            • 感谢您的所有回答先生 :) 但是当我问谁有主机时,他立即修复了我的错误。将我的 htaccess 更改为他的 htaccess。我稍后会粘贴我的新 htaccess
            猜你喜欢
            • 2012-05-01
            • 1970-01-01
            • 2014-08-21
            • 2014-11-25
            • 1970-01-01
            • 2016-09-22
            • 2017-04-05
            • 1970-01-01
            • 2013-02-06
            相关资源
            最近更新 更多