CodeIgniter 500 server error - php

I have a question that has had me pulling my hair over the last few weeks.. i have been having a blast developing a Codeigniter website on my local machine and everything functions as normal on the local machine, however when i upload the site to the production server then the links stop working and whenever clicked give me a 500 internal server error also ajax post requests also generate a 500 internal error from the console. I m really stumped as to what the problem could be thats why i have come to ask here, could anybody help me please. Also i don't have shell access
this is my htaccess file
<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>

use this as .htaccess
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_URI} ^sys.*
RewriteRule ^(.*)$ /index.php?/$1 [L]
RewriteCond %{REQUEST_URI} ^app.*
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'] = '';
if you are using sub domain set it as the RewriteBase

Related

Page not found in sub pages of admin panel in live server

I have hosted a website of codeigniter framework by using godaddy server.
The website is working nicely. And home page of admin panel is also working, but after first, the sub pages are giving page not found error, when I am trying to log in.
I think its a url directions error.
From Comment
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
Options -Indexes
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>
The below settings works for me:
First change this valiables in /application/config/config.php
$config['base_url'] = 'http://example.com/';
$config['index_page'] = '';
$config['uri_protocol'] = 'REQUEST_URI';
Then change in .htaccess file
RewriteEngine on
Options -Indexes
RewriteCond $1 !^(index\.php|resources|robots\.txt)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/$1 [QSA,L]

Transfer CodeIgniter project local to server, admin panel not working

I create CodeIgniter project on my local machine (Running perfectly), then I uploaded to a server with its database but I am facing the problem of not found an error while opening admin panel.
I changed config file(for base URL), database.php(for database connection).
but I don't know what to change in the .htaccess file, I took a default CodeIgniter .htaccess file but it is showing not found error.
htaccess file :
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /crescent_test/ad_crescent/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/$1 [L]
</IfModule>
<IfModule !mod_rewrite.c>
ErrorDocument 404 /index.php
</IfModule>
Try this updated code.
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond $1 !^(index\.php|resources|robots\.txt)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/$1 [L,QSA]
</IfModule>
if this does not work then visit below link:
Page isn't working and returns HTTP error 500 in CodeIgniter
you can try this:
add htaccess file YOUR_ADMIN_FLODER root
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /YOUR_ADMIN_FLODER_NAME/
Options -Indexes
RewriteCond %{REQUEST_URI} ^system.*
RewriteRule ^(.*)$ /YOUR_ADMIN_FLODER_NAME/index.php?/$1 [L]
RewriteCond %{REQUEST_URI} ^application.*
RewriteRule ^(.*)$ /YOUR_ADMIN_FLODER_NAME/index.php?/$1 [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /YOUR_ADMIN_FLODER_NAME/index.php?/$1 [L]
</IfModule>
<IfModule !mod_rewrite.c>
ErrorDocument 404 /YOUR_ADMIN_FLODER_NAME/index.php
</IfModule>

redirecting subdomain to main domain with htaccess

I am building a website with two main sections,
so I have created two subdomains:
web1.example.com
web2.example.com
since i'm building websites with codeigniter, I want to redirect to the index.php page. here's what I did:
RewriteEngine On
RewriteCond %{HTTP_HOST} ^web1.example.com$ [NC]
RewriteRule ^(.*)$ http://example.com/web1 [R=301,NC,L]
it works as expected, but it changes the url to example.com/web1..
is there any way to keep the url web1.example.com, but still redirecting to example.com/web1?
I already am using .htaccess file:
<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>
when I enter web1.example.com, the actual url to be executed should be:
example.com/web1, and file to be executed is index.php ..
Didnt tested, Modify and try this
RewriteRule ^([a-zA-Z0-9-/]+).example.com$ http://example.com/$1 [L]
RewriteRule ^([a-zA-Z0-9-/]+).example.com/([a-zA-Z0-9-/]+) http://example.com/$1&$2 [L]
Edited 1
RewriteEngine on
RewriteCond %{HTTP_HOST} ^(.*)\.example\.com
RewriteRule ^(.*)$ http://example.com/index.php/%1&$1 [L,NC,QSA]

VHost & htaccess - 500 Internal Server error

I use ISPConfig 3 to manage my domains/subdomains.
I added subdomain parim.kristian.ee which would redirect to web/parim/ (note: web/ is my document root).
ISPConfig generated such redirect to apache config:
RewriteEngine on
RewriteCond %{HTTP_HOST} ^parim.kristian.ee [NC]
RewriteRule ^/(.*)$ /parim/$1 [L]
Now if i'll try to get static resources, such as http://parim.kristian.ee/images/1x1.gif, it serves fine, but when redirect is to codeigniter, it doesn't work.
Htaccess in web/parim/ looks like this:
<IfModule mod_rewrite.c>
RewriteEngine on
Options -Indexes
#Handle CodeIgniter request
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ ./index.php?/$1 [L]
</IfModule>
<IfModule !mod_rewrite.c>
ErrorDocument 404 ./index.php
</IfModule>
NOTE: accessing the same folder via http://kristian.ee/parim/ works!
I s*ck at htaccess, so any help is appreciated.
# To remove index.php from URL
RewriteEngine On
RewriteBase /parim
RewriteCond %{REQUEST_URI} ^system.*
RewriteRule ^(.*)$ /index.php/$1 [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]
Or Simple remove RewriteBase /parim

Problem with .htaccess and index.php

In my development server the, the referrer name will look like dev.host.in and the ip will look like 123.456.456.111/dev/
I am using codeigniter framework. I have already set the .htaccess file to remove the index.php. When I'm accessing site through dev.host.in/testproject/ its working fine. But when I'm accessing it with 123.456.456.111/dev/testproject/ it doesn't display the page.
But when I access 123.456.456.111/dev/testproject/index.php I am getting the site.
How to resolve this issue?
Put this in your .htaccess file:
<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>
If you're still having problems, visit this link.

Categories