<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/$1 [L]
</IfModule>
This works for me.
Question
I'm using this code to rewrite in htaccess
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php?/$1 [L]
</IfModule>
<IfModule !mod_rewrite.c>
ErrorDocument 404 /index.php
</IfModule>
It works fine in example.com/sub
, but in sub.example.com
it gives 500 internal server error
(except for the landing page).
I can't understand what wrong here. Sometimes it may be very simple. I'm using GoDaddy.
Error log.
[Tue Feb 11 00:32:51 2014] [11333226] [core:error] [client 122.174.192.156:15900] AH00124: Request exceeded the limit of 10 internal redirects due to probable configuration error. Use 'LimitInternalRecursion' to increase the limit if necessary. Use 'LogLevel debug' to get a backtrace.
[Wed Feb 12 03:03:37 2014] [11333226] [core:error] [client 122.174.232.6:16075] AH00124: Request exceeded the limit of 10 internal redirects due to probable configuration error. Use 'LimitInternalRecursion' to increase the limit if necessary. Use 'LogLevel debug' to get a backtrace., referer http://sub.example.com/
[Wed Feb 12 03:03:37 2014] [11333226] [core:error] [client 122.174.232.6:16069] AH00124: Request exceeded the limit of 10 internal redirects due to probable configuration error. Use 'LimitInternalRecursion' to increase the limit if necessary. Use 'LogLevel debug' to get a backtrace., referer http://sub.example.com/
[Wed Feb 12 03:03:37 2014] [11333226] [core:error] [client 122.174.232.6:16079] AH00124: Request exceeded the limit of 10 internal redirects due to probable configuration error. Use 'LimitInternalRecursion' to increase the limit if necessary. Use 'LogLevel debug' to get a backtrace., referer http://sub.example.com/
[Wed Feb 12 03:03:38 2014] [11333226] [core:error] [client 122.174.232.6:16081] AH00124: Request exceeded the limit of 10 internal redirects due to probable configuration error. Use 'LimitInternalRecursion' to increase the limit if necessary. Use 'LogLevel debug' to get a backtrace., referer http://sub.example.com/
[Wed Feb 12 03:03:40 2014] [11333226] [core:error] [client 122.174.232.6:16082] AH00124: Request exceeded the limit of 10 internal redirects due to probable configuration error. Use 'LimitInternalRecursion' to increase the limit if necessary. Use 'LogLevel debug' to get a backtrace., referer http://sub.example.com/
Solution
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/$1 [L]
</IfModule>
This works for me.
OTHER TIPS
You can try this code:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^((?!index\.php).*)$ index.php?/$1 [L]
</IfModule>
<IfModule !mod_rewrite.c>
ErrorDocument 404 /index.php
</IfModule>
Try this:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_URI} ^system.*
RewriteRule ^(.*)$ /index.php?/$1 [L]
RewriteCond %{REQUEST_URI} ^application.*
RewriteRule ^(.*)$ /index.php?/$1 [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/$1 [L]
</IfModule>
<IfModule !mod_rewrite.c>
ErrorDocument 404 /index.php
</IfModule>
assumming that index.php is your index page.
and change in config.php
$config['index_page'] = '';
I had the same problem, even with .htaccess written properly. Took me a moment to realize the file permissions were wrong. Doh!!!
IMPORTANT: PHP files must not have 777 permissions. If you are trying to open a PHP file that has such permissions, it will result in an "Internal Server Error 500". To resolve the problem, simply change the permissions of the file to 644 or 755.