Codeigniter without index.php changing in config and .htaccess not working - php

I have this issue with codeigniter for my subdomain where I would like to take out index.php but is not working for some reason.
I have set .htaccess with below:
RewriteEngine on
RewriteCond $1 !^(index\.php|images|captcha|css|js|user_guide|robots\.txt)
RewriteRule ^(.*)$ index.php/$1 [L]
and also config.php index_page settings have been changed like below:
$config['index_page'] = '';
do you know why it's not working?

And this is mine
DirectoryIndex index.php
RewriteEngine on
RewriteCond $1 !^(index\.php|(.*)\.swf|forums|images|css|downloads|js|robots\.txt|favicon\.ico)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ ./index.php?$1 [L,QSA]

This is how mine is currently setup, hope this helps.
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/$1 [L]

Related

Codeigniter in localhost

I don't understand .htaccess yet. I have problem codeigniter application doesn't work in localhost my application is in this folder sturcture
C:/xampp/htdocs/dev.application.pl/public_html/
My config.php is
$config['base_url'] = 'http://localhost/dev.application.pl/';
And in folder dev.application.php/ i have .htaccess like this
RewriteEngine On
RewriteBase /public_html
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]
But this doesn't work.
Edit your .htaccess to this:
RewriteEngine On
RewriteBase /dev.application.pl/public_html
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]
Hope it helps :)
Edit your hosts file and add
127.0.0.1 dev.application.pl
$config['base_url'] = 'http://dev.application.pl/';
htaccess:
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]

Codeigniter remove index.php from URL localhost:82/project

I have URL
http://localhost:82/project/index.php/home
I want to remove index.php from above url.
Like this : http://localhost:82/project/home
I have used many solution
1) I have remove index.php from config.php file :
$config['index_page'] = '';
2) change "uri_protocol" in config.php file :
$config['uri_protocol'] = 'REQUEST_URI';
My htaccess :
RewriteEngine On
RewriteBase /project/
RewriteCond %{REQUEST_URI} ^system.*
RewriteCond $1 !^(index\.php|images|js|uploads|css|robots\.txt)
RewriteRule ^(.*)$ /index.php/$1 [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]
Anybody master here to solve my question ? Thanks in advance.
use this Codeigniter .htaccess file and install it to your root app.
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]
</IfModule>
Like this one...
project_name
-application
-assets
-system
-user_guide
-.htaccess // like this one
Try To Use This
RewriteEngine on
#RewriteBase /project/
RewriteCond $1 !^(index\.php|images|admin|robots\.txt)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond $1 !^(index\.php|images|admin|robots\.txt)
RewriteRule .* index.php/$0 [PT,L]
I use it and work on me.
Thank You
Set your base URL in config as
$config['base_url'] = 'http://localhost:82/project/'
In your .htaccess, Try with this, I have used this in my CI projects.
RewriteEngine on
RewriteCond $1 !^(index\.php|resources|robots\.txt)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L,QSA]
Place this file in your project folder.
If you are using Apache Server, you must do mod_rewrite enabled. And then modify your .htaccess file with the code below.
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]
For more information, visit here
Try similar question here

.htaccess is not working in codeigniter

I have started working with codeigniter and wanted to remove index.php in the URL /testing_palace/index.php/home to /testing_palace/home, working in localhost.
I google'ed the problem and tried the solutions suggested but didn't worked for me.
I changed base_url and index page in config to
$config['base_url']= 'http://localhost/testing_palace/';
$config['index_page'] ="";
And checked mod_rewrite on windows apache is enabled.
Here is my .htaccess code
RewriteEngine On
RewriteBase /testing_palace
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]
All these solutions is not working for me getting not found Error.
Have your /testing_palace/.htaccess like this:
RewriteEngine on
RewriteBase /testing_palace/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /index.php/$1 [L]
then in /testing_palace/application/config/config.php you need to have these config settings:
$config['base_url'] = '';
$config['index_page'] = '';
$config['uri_protocol'] = 'AUTO';
Use the following .htaccess.
RewriteEngine on
RewriteCond $1 !^(index\.php|resources|robots\.txt)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L,QSA]
I think it will help you.

CI url formating not working

i am currently working with CI. I need some help with removing index.php from url.
I tried a lot and could not figure out my issue. I checked solution but was not helpful.
My .htaccess file ->
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]
also changed
$config['index_page'] = 'index.php';
to:
$config['index_page'] = '';
and made $config['base_url'] = 'my working url';
can anyone help ???
Can you try with this .htaccess :
Options -Indexes
Options -MultiViews
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_URI} ^system.*
RewriteRule ^(.*)$ /index.php/$1 [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]

Removing index.php of codeigniter on local

I'm trying to remove index.php,in my localhost, but it seems doesn't working,its on http://localhost/testing.
I put .htacces in 'testing' directory under the htdocs.
LoadModule rewrite_module modules/mod_rewrite.so
at Apache/conf also already unchecked.
Here my .htaccess:
RewriteEngine On
RewriteBase /testing/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /testing/index.php/$1 [L]
Here my config:
$config['base_url'] = "http://localhost/testing";
$config['index_page'] = '';
$config['uri_protocol'] = 'AUTO';
When I access login controller, it's not found.
Not Found
The requested URL /testing/login was not found on this server.
I really don't know what to try next. Any help would be appreciated.
Try this :-
Config.php :-
$config['base_url'] = 'http://localhost/testing/';
$config['index_page'] = '';
.htaccess
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]
Your htaccess should be like
RewriteEngine On
RewriteBase /testing/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]
There's no need to append /testing/ since RewriteBase already takes care of that.
basically the index.php is included in all URLs:
we can remove this using .htaccess with a simple rules. following is an example of such a file, using the "negative" method in which everything is redirected,
RewriteEngine on
RewriteBase /testing/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /index.php/$1 [L]
now restart your server and check
Leave out the trailing slash in RewriteBase:
RewriteEngine On
RewriteBase /testing
RewriteCond $1 !^(index\.php|robots\.txt)
RewriteRule ^(.*)$ index.php/$1 [L]
$config['base_url'] should be http://localhost/testing/
$config['index_page'] should be blank.
Try this one in the .htaccess file:
RewriteEngine on
RewriteCond $1 !^(index\.php|robots\.txt|resources)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?$1 [L]
ErrorDocument 404 /mainpage
your config file is fine
Difference being the "?" after index.php
You may also want to try changing the value of $config[‘uri_protocol’] in ./application/config/config.php. Sometimes CodeIgniter gets it wrong. Changing it to PATH_INFOmight work.

Categories