CodeIgniter .htaccess - 500内部服务器错误/ index.php删除

时间:2016-01-11 05:34:26

标签: php apache .htaccess codeigniter mod-rewrite

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

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文件?或者我的目录中出错的任何其他文件?

5 个答案:

答案 0 :(得分:3)

使用此

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

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

这是Codeigniter推荐的.htaccess

  

答案 1 :(得分:0)

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

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

答案 2 :(得分:0)

尝试这两个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.

答案 3 :(得分:0)

这是我的新.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>

答案 4 :(得分:-1)

试试这个: 如果您在本地系统上使用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>