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

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]

Related

Codeigniter not working in subfolder of root wordpress website

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>

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.

codeigniter removing index.php from url in wamp

I have big problem trying to remove index.php from url's
i have searched lots if forums (this also), but no help for my situation.
so i have config.php file
$config['base_url'] = '';
$config['index_page'] = '';
$config['uri_protocol'] = 'AUTO';
my .htaccess file in public_html folder near index.php
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /public_html/
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>
and in WAMP apache (ver.: 2.4.9) i have rewrite_module ON (and it's working)
and my httpd.conf AllowOverride set to All
so when i am going to mydomain.com/controller/action - I get 404
but when i go to mydomain.com/index.php/controller/action - everything is OK..
i have tried lots of .htaccess examples... and so on.. nothing helps..
Use this htacess and then go to config.php and remove index.php
Options +FollowSymLinks
Options -Indexes
DirectoryIndex index.php
RewriteEngine on
RewriteCond $1 !^(index\.php|images|robots\.txt)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L,QSA]

CodeIgniter 500 server error

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

how to skip index.php and method name in url of codeigniter 1.7.2?

I am newbie with Codeigniter 1.7.2. I want to skip index.php and method name of Site URL. But I don't know how to skip them.
My site url looks like -
http://localhost/mysadagi_voicetongues/index.php/deal_bazaar/PrivilegeDealsbazaar
So I want skip index.php and PrivilegeDealsbazaar from url.
Please give solution to fix this issue.
Thanks
Use latest version on CI 2.1.3
You can use .htaccess to hide index.php from URL. You can use following .htaccess
<IfModule mod_rewrite.c>
RewriteEngine On
#AddHandler application/x-httpd-php5 .php
RewriteBase /projectforlder/
RewriteCond %{REQUEST_URI} ^system.*
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>
You can not access your controller without specifying it in URL.
you can do this in 3 steps:
1) Create .htacess file in parallel to application holder
and just copy past the following code:
RewriteEngine On
RewriteBase /CodeIgniter/ /* this will be your prj name. Change it as per your directory structure*/
RewriteCond %{REQUEST_URI} ^system.*
RewriteRule ^(.*)$ /index.php/$1 [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]
2) Change $config['index_page'] to blank in config.php in application folder as below:
$config['index_page'] = '';
3) Enable "rewrite_module" of apache.
I forget to tell. open your config file: application/config/config.php and change this line
$config['index_page'] = “index.php”
To
$config['index_page'] = “”
Create a .htaccess file in the root of your app so
system
application
assets
.htaccess
To delete the index.php from your url use this .htaccess file:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_URI} ^system.*
RewriteRule ^(.*)$ index.php?/$1 [L]
RewriteCond %{REQUEST_URI} ^LoginTut.*
RewriteRule ^(.*)$ index.php?/$1 [L]
RewriteCond $1 !^(index\.php|images|table-images|js|robots\.txt|css|captcha)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?$1 [L]
</IfModule>
<IfModule !mod_rewrite.c>
ErrorDocument 404 index.php
</IfModule>
It's not a very good idea to hide the controller name because you will get a lot of problems when routing and linking to other functions.
Hope it helps!

Categories