CodeIgniter .htaccess - 500 Internal Server Error/

2019-01-27 05:08发布

问题:

I have a website like this (sub-domain)

rabbani.websolocom.xyz

And I have the .htaccess code like this (I used 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]

But when I try to access my website it goes error (500 Internal Server Error). What should i do with my .htaccess file? Or any another file that wrong in my directory?

回答1:

Use this

.htaccess(Outside application folder)

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

This is Codeigniter recommended .htaccess



回答2:

Place the .htaccess inside the rabbani folder Like This

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


回答3:

Try these two 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]

And

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

More htaccess here.



回答4:

This is my new .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:

Try this: if you are using codeigniter on local system

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

If you are using it on server then use this:

<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>