简体   繁体   中英

Codeigniter mod_rewrite gives server 500 error

I get an server 500 error with this htaccesss file in my xampp enviorment.

My $config['index_page'] variable is set to ''

C:/xampp/htdocs/codeigniter_test/.htaccess

<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /codeigniter_test/

#Removes access to the system folder by users.
#Additionally this will allow you to create a System.php controller,
#previously this would not have been possible.
#'system' can be replaced if you have renamed your system folder.
    RewriteCond %{REQUEST_URI} ^system.*
    RewriteRule ^(.*)$ /index.php?/$1 [L]

#When your application folder isn't in the system folder
#This snippet prevents user access to the application folder
#Submitted by: Fabdrol
#Rename 'application' to your applications folder name.
    RewriteCond %{REQUEST_URI} ^application.*
    RewriteRule ^(.*)$ /index.php?/$1 [L]

#Checks to see if the user is attempting to access a valid file,
#such as an image or css document, if this isn't true it sends the
#request to index.php
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.*)$ index.php?/$1 [L]
</IfModule>
<IfModule !mod_rewrite.c>
# If we don't have mod_rewrite installed, all 404's
# can be sent to index.php, and everything works as normal.
# Submitted by: ElliotHaughin

    ErrorDocument 404 /index.php
</IfModule> 

So if I go to localhost/codeigniter_test/site/home now I get this server 500 error.

site = controller and home = function in the site controller which loads up the home view

Also localhost/codeigniter_test/site/about is not working for me. I don't get any 404 page so this means my mod_rewrite module is enabled. I also checked this in my httpd.conf file.

Apache logs says:

[core:alert] [pid 1484:tid 512] [client 127.0.0.1:3870] C:/xampp/htdocs/codeigniter_test/.htaccess:

Edit: So I just removed the entire IF part. Now localhost/codeigniter_test/ works. But if I go to localhost/codeigniter_test/site/home it doesnt work and I get an 404 page.

Edit2: I change AllowOverride None to AllowOverride All in my httpd conf file. Now I get a 403 error when I go to: localhost/codeigniter_test/site/home/

"The requested URL /codeigniter_test/site/home was not found on this server."

I got similar issue, basically, it's a permission issue:

try granting 755 permission on the folders and subfolders

chmod 755 *
chmod 755 */*
chmod 755 */*/*
chmod 755 */*/*/*
chmod 755 */*/*/*/*

I only have this in my .htaccess file

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule .* index.php/$0 [PT,L]

Hope that helps

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM