Codeigniter not working in subfolder of root wordpress website - php

I upload the codeigniter in the subfolder and in the root I have a wordpress webstie. I change the config base url with the name of subfolder name like this
$config['base_url'] = 'http://xxxxxxxxxxxx.com/onlinebooks/';
But after this still getting 404 for any controller I call on url
Can Anybody help me regarding this?

Try this
Create a .HtaAccess in root folder and paste this
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/$1 [L]
</IfModule>
<IfModule !mod_rewrite.c>
ErrorDocument 404 /index.php
</IfModule>

404, maybe you have modified your code to remove the index.php on the url, this would be the correct .htaccess.
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /onlinebooks/
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
RewriteCond $1 !^(index\.php|images|stylesheets|javascript)
RewriteRule ^(.*)$ index.php?/$1 [L]
</IfModule>
<IfModule !mod_rewrite.c>
ErrorDocument 404 /index.php
</IfModule>

Related

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>

404 page not found while page redirection in codeigniter

Hi all I tried to redirect to dashboard controller addLocation function under admin folder i have given the link below its showing 404 page not found,
http://localhost/kooly/admin/dashboard/addLocation
This is my htaccess file help me to solve this redirection problem
.htaccess
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /kooly/
DirectoryIndex index.php
RewriteEngine on
RewriteCond $1 !^(index\.php|images|css|js|robots\.txt|favicon\.ico)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ ./index.php/$1 [L,QSA]
</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>
Try this and save outside of your application folder
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /your folder/
RewriteCond %{REQUEST_URI} ^system.*
RewriteRule ^(.*)$ /index.php?/$1 [L]
RewriteCond %{REQUEST_URI} ^application.*
RewriteRule ^(.*)$ /index.php?/$1 [L]
RewriteCond $1 !^(index\.php|assets|images|robots\.txt)
RewriteRule ^(.*)$ index.php/$1 [L]
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.
ErrorDocument 404 /index.php
</IfModule>
Try the below .htaccess code.
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule .* index.php?/$0 [PT,L]
RewriteRule ^/?ajax/(.*)$ ajax.php?$1 [NC,QSA,L]
<IfModule mod_headers.c>
header add Access-Control-Allow-Origin: "*"
</IfModule>
You can add this code into your .htaccess file
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
# Rewrite all other URLs to index.php/URL
RewriteRule ^(.*)$ index.php?url=$1 [PT,L]
</IfModule>
<IfModule !mod_rewrite.c>
ErrorDocument 404 index.php
</IfModule>
It's working for me using codeigniter 3.
I hope it will work for you!!

CodeIgniter | Certain controllers won't load depending on .htaccess?

I have two controllers inside my CodeIgniter project.
- home.php
- dashboard.php
For some reason, my htaccess makes dashboard.php unavailable when I change it to this:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /ci_intro/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/$1 [L] # THIS LINE HERE
</IfModule>
<IfModule !mod_rewrite.c>
ErrorDocument 404 /index.php
</IfModule>
However, when I change it to the code below, home.php is unavailable.
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /ci_intro/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L] # THIS LINE HERE
</IfModule>
<IfModule !mod_rewrite.c>
ErrorDocument 404 /index.php
</IfModule>
I don't understand why, anyone have an idea of why it would do this?
Thanks,
Scott
Try these:
<IfModule mod_rewrite.c>
Options +FollowSymLinks
RewriteBase /ci_intro
RewriteEngine On
RewriteCond %{HTTP_HOST} !^www\.
RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L]
#Send request via index.php
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/$1 [L]
</IfModule>
And make controller home.php as class Home extends CI_Controller and Rename it as Home.php Same for dashboard.php

CodeIgniter always shows 404 error

I am using codeigniter-3 and I have set its default controller in routes.php as
$route['default_controller'] = 'home';
I have set the Virtual Host for this project and my .htaccess looks like this
<IfModule mod_headers.c>
Header set Access-Control-Allow-Origin "*"
</IfModule>
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/$1 [L]
RewriteRule !^[A-Za-z0-9_/\-\.]*$ - [L,R=404]
</IfModule>
<IfModule !mod_rewrite.c>
ErrorDocument 404 /index.php
</IfModule>
My config.php is like
$config['index_page'] = '';
It is working fine if the default controller is set to welcome
If your folder tree is something like this : htdocs/codeigniter/
Then use the following codes in .htaccess file :
RewriteEngine On
RewriteBase /codeigniter
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]
And check your controller class name and file name if same.

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

Categories