Create a gist now

Instantly share code, notes, and snippets.

Embed
CI: Simple .htaccess using mod_rewrite for CodeIgniter
<IfModule mod_rewrite.c>
RewriteEngine On
# !IMPORTANT! Set your RewriteBase here and don't forget trailing and leading
# slashes.
# If your page resides at
# http://www.example.com/mypage/test1
# then use
# RewriteBase /mypage/test1/
RewriteBase /
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.
# Submitted by: ElliotHaughin
ErrorDocument 404 /index.php
</IfModule>
@KungRaseri

This comment has been minimized.

Show comment
Hide comment
@KungRaseri

KungRaseri Jun 28, 2013

Worked perfectly :) Thanks man

Worked perfectly :) Thanks man

@jfitzsimmons2

This comment has been minimized.

Show comment
Hide comment
@jfitzsimmons2

jfitzsimmons2 Sep 9, 2013

Brilliant, thanks for sharing.

Brilliant, thanks for sharing.

@panvagenas

This comment has been minimized.

Show comment
Hide comment
@panvagenas

panvagenas Oct 7, 2013

Thanks man!

Thanks man!

@ghost

This comment has been minimized.

Show comment
Hide comment
@ghost

ghost Oct 9, 2013

Thanks!

ghost commented Oct 9, 2013

Thanks!

@amirak17

This comment has been minimized.

Show comment
Hide comment
@amirak17

amirak17 Oct 13, 2013

Thanks a lot Philip. God bless you.

Thanks a lot Philip. God bless you.

@fadsel

This comment has been minimized.

Show comment
Hide comment
@fadsel

fadsel Feb 12, 2014

Brilliant :D

fadsel commented Feb 12, 2014

Brilliant :D

@haidarvm

This comment has been minimized.

Show comment
Hide comment
@haidarvm

haidarvm Feb 26, 2014

thanks ...

thanks ...

@Kerollmops

This comment has been minimized.

Show comment
Hide comment
@Kerollmops

Kerollmops Apr 18, 2014

Thanks man !

Thanks man !

@rahulsompura

This comment has been minimized.

Show comment
Hide comment
@rahulsompura

rahulsompura May 15, 2014

Nice ... Man It Works....>>>>!@

Nice ... Man It Works....>>>>!@

@rahulsompura

This comment has been minimized.

Show comment
Hide comment
@rahulsompura

rahulsompura May 15, 2014

Nice ... Man It Works....>>>>!@

Nice ... Man It Works....>>>>!@

@rahulsompura

This comment has been minimized.

Show comment
Hide comment
@rahulsompura

rahulsompura May 15, 2014

Nice ... Man It Works....>>>>!@

Nice ... Man It Works....>>>>!@

@rahulsompura

This comment has been minimized.

Show comment
Hide comment
@rahulsompura

rahulsompura May 15, 2014

Nice ... Man It Works....>>>>!@

Nice ... Man It Works....>>>>!@

@rahulsompura

This comment has been minimized.

Show comment
Hide comment
@rahulsompura

rahulsompura May 15, 2014

Nice ... Man It Works....>>>>!@

Nice ... Man It Works....>>>>!@

@rahulsompura

This comment has been minimized.

Show comment
Hide comment
@rahulsompura

rahulsompura May 15, 2014

Nice ... Man It Works....>>>>!@

Nice ... Man It Works....>>>>!@

@trfiladelfo

This comment has been minimized.

Show comment
Hide comment
@trfiladelfo

trfiladelfo Jun 5, 2014

Thanks Man, it perfect works...

Thanks Man, it perfect works...

@HACK21

This comment has been minimized.

Show comment
Hide comment
@HACK21

HACK21 Jul 1, 2014

Thx !

HACK21 commented Jul 1, 2014

Thx !

@pradeepnama2009

This comment has been minimized.

Show comment
Hide comment
@pradeepnama2009

pradeepnama2009 Jul 5, 2014

Thanks :)

Thanks :)

@rajakannan

This comment has been minimized.

Show comment
Hide comment
@rajakannan

rajakannan Jul 21, 2014

love it !

love it !

@HelgeSverre

This comment has been minimized.

Show comment
Hide comment
@HelgeSverre

HelgeSverre Jul 21, 2014

Thanks gives 1 free internet

Thanks gives 1 free internet

@gnabino1

This comment has been minimized.

Show comment
Hide comment
@gnabino1

gnabino1 Jul 23, 2014

it didnt work ..........why???????????????

it didnt work ..........why???????????????

@joshlminga

This comment has been minimized.

Show comment
Hide comment
@joshlminga

joshlminga Sep 4, 2014

It worked perfectly for CodeIgniter 2.2

It worked perfectly for CodeIgniter 2.2

@kmwalsh

This comment has been minimized.

Show comment
Hide comment
@kmwalsh

kmwalsh Sep 9, 2014

Thank you so much! I inherited a CodeIgniter project. I'd tried literally every other result for a fix (switching uri_protocol and index_page in config, a few different .htaccess files, etc.) and this worked on the first shot. Thanks again!

kmwalsh commented Sep 9, 2014

Thank you so much! I inherited a CodeIgniter project. I'd tried literally every other result for a fix (switching uri_protocol and index_page in config, a few different .htaccess files, etc.) and this worked on the first shot. Thanks again!

@chandu4ugandhi

This comment has been minimized.

Show comment
Hide comment
@chandu4ugandhi

chandu4ugandhi Jan 28, 2015

I am having a problem in my codeigniter site. Its not deleting or showing any nested files like this is url:

http://domain.com/project/admin/posts/delete/94

Its just showing the post index page only.

I am having a problem in my codeigniter site. Its not deleting or showing any nested files like this is url:

http://domain.com/project/admin/posts/delete/94

Its just showing the post index page only.

@xsolz-abhishek

This comment has been minimized.

Show comment
Hide comment
@xsolz-abhishek

xsolz-abhishek Feb 10, 2015

Why not the below code working as it is given to user guide??
RewriteEngine on
RewriteCond $1 !^(index.php|images|robots.txt)
RewriteRule ^(.*)$ /index.php/$1 [L]

Why not the below code working as it is given to user guide??
RewriteEngine on
RewriteCond $1 !^(index.php|images|robots.txt)
RewriteRule ^(.*)$ /index.php/$1 [L]

@ton-ton

This comment has been minimized.

Show comment
Hide comment
@ton-ton

ton-ton Feb 26, 2015

Hey, how to modify this in order to work it well in GoDaddy? Thanks.

ton-ton commented Feb 26, 2015

Hey, how to modify this in order to work it well in GoDaddy? Thanks.

@virdisss

This comment has been minimized.

Show comment
Hide comment
@virdisss

virdisss Mar 15, 2015

Thanks, i appreciate!

Thanks, i appreciate!

@ztobs

This comment has been minimized.

Show comment
Hide comment
@ztobs

ztobs Apr 14, 2015

hello developers, im quite new to CI. Ive been developing a CI project for a while on my local machine and all has been working fine. Then i tried hosting it on the production server and all i get is

500 - Internal server error.
There is a problem with the resource you are looking for, and it cannot be displayed.

Has someone experienced this before. Your contribution would be highly appreciated.

ztobs commented Apr 14, 2015

hello developers, im quite new to CI. Ive been developing a CI project for a while on my local machine and all has been working fine. Then i tried hosting it on the production server and all i get is

500 - Internal server error.
There is a problem with the resource you are looking for, and it cannot be displayed.

Has someone experienced this before. Your contribution would be highly appreciated.

@prashanthsandela

This comment has been minimized.

Show comment
Hide comment
@prashanthsandela

prashanthsandela May 14, 2015

Thanks.. 😄 This reduced lot of research. I appreciate it..

Thanks.. 😄 This reduced lot of research. I appreciate it..

@maddbr

This comment has been minimized.

Show comment
Hide comment
@maddbr

maddbr May 16, 2015

Thanks again.

maddbr commented May 16, 2015

Thanks again.

@usamamashkoor

This comment has been minimized.

Show comment
Hide comment
@usamamashkoor

usamamashkoor Jun 16, 2015

How can i replace search with pakistan in the given url
http://www.mysite.pk/jobs/search/faisalabad/all-cats

I want to change it to http://www.mysite.pk/jobs/pakistan/faisalabad/all-cats
How can i do this using .htaccess

How can i replace search with pakistan in the given url
http://www.mysite.pk/jobs/search/faisalabad/all-cats

I want to change it to http://www.mysite.pk/jobs/pakistan/faisalabad/all-cats
How can i do this using .htaccess

@cstanda

This comment has been minimized.

Show comment
Hide comment
@cstanda

cstanda Jul 9, 2015

Great, Thanks!

cstanda commented Jul 9, 2015

Great, Thanks!

@RGKrish183

This comment has been minimized.

Show comment
Hide comment
@RGKrish183

RGKrish183 Jul 18, 2015

hey, i'm newbie for ci. i've try to remove index.php file,.. but i can't get it.

i've try the following .htaccess file

RewriteEngine On

RewriteBase /jtrack/

My sudir is jtrack - like localhost/jtrack/index.php/controller/function

but, I need to redir - like localhost/jtrack/controller/function

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 !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

And, in my config file like as

$config['base_url'] = '';

$config['index_page'] = 'index.php';

$config['uri_protocol'] = 'AUTO';

in my php was looks like,

$this->load->helper('url');

thanks for reading query...

hey, i'm newbie for ci. i've try to remove index.php file,.. but i can't get it.

i've try the following .htaccess file

RewriteEngine On

RewriteBase /jtrack/

My sudir is jtrack - like localhost/jtrack/index.php/controller/function

but, I need to redir - like localhost/jtrack/controller/function

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 !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

And, in my config file like as

$config['base_url'] = '';

$config['index_page'] = 'index.php';

$config['uri_protocol'] = 'AUTO';

in my php was looks like,

$this->load->helper('url');

thanks for reading query...

@bionic2k

This comment has been minimized.

Show comment
Hide comment
@bionic2k

bionic2k Jul 27, 2015

Change the following Vars in your "application/config/config.php" File:

$config['base_url'] = 'http://domain.com/subfolder/';

This should never be empty. Include full URL to your Website´s DocRoot and don´t forget the Trailing Slash at the end.

$config['index_page'] = ' '; Remove index.php entry, now your .htaccess File makes routing to index.php

Hope it can help you ;)

The following entrys were not needed unless you want to add a System- or Application-Controller.
htaccess File prevent access to the system and application folder.

RewriteCond %{REQUEST_URI} ^system.*
RewriteRule ^(.*)$ /index.php?/$1 [L]

RewriteCond %{REQUEST_URI} ^application.*
RewriteRule ^(.*)$ /index.php?/$1 [L]

Here is the content of my .htaccess File for CI

<IfModule mod_rewrite.c>

RewriteEngine On
RewriteBase /subfolder/

# Canonicalize Codeigniter URLs

# If your default controller is something other than
# "welcome" you should probably change this
RewriteRule ^(welcome(/index)?|index(\.php|html?)?)/?$ / [R=301,L]
RewriteRule ^(.*)/index/?$ $1 [L,R=301]

# Removes trailing slashes (prevents SEO duplicate content issues)
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.+)/$ $1 [R=301,L]

# Enforce www
# If you have subdomains, you can add them to 
# the list using the "|" (OR) regex operator
RewriteCond %{HTTP_HOST} !^(www|subdomain) [NC]
RewriteRule ^(.*)$ http://www.domain.com/$1 [R=301,L]

# Enforce no-www
#RewriteCond %{HTTP_HOST} ^www [NC]
#RewriteRule ^(.*)$ http://domain.com/$1 [L,R=301]

# Removes access to the system folder by users.
# Additionally this will allow you to create a System.php controller,
# previously this would not have been possible.
# 'system' can be replaced if you have renamed your system folder.
# RewriteCond %{REQUEST_URI} ^system.*
# RewriteRule ^(.*)$ /index.php/$1 [L]

# Checks to see if the user is attempting to access a valid file,
# such as an image or css document, if this isn't true it sends the
# request to index.php
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]

</IfModule>

<IfModule !mod_rewrite.c>

# Without mod_rewrite, route 404's to the front controller
ErrorDocument 404 /index.php

</IfModule>

Change the following Vars in your "application/config/config.php" File:

$config['base_url'] = 'http://domain.com/subfolder/';

This should never be empty. Include full URL to your Website´s DocRoot and don´t forget the Trailing Slash at the end.

$config['index_page'] = ' '; Remove index.php entry, now your .htaccess File makes routing to index.php

Hope it can help you ;)

The following entrys were not needed unless you want to add a System- or Application-Controller.
htaccess File prevent access to the system and application folder.

RewriteCond %{REQUEST_URI} ^system.*
RewriteRule ^(.*)$ /index.php?/$1 [L]

RewriteCond %{REQUEST_URI} ^application.*
RewriteRule ^(.*)$ /index.php?/$1 [L]

Here is the content of my .htaccess File for CI

<IfModule mod_rewrite.c>

RewriteEngine On
RewriteBase /subfolder/

# Canonicalize Codeigniter URLs

# If your default controller is something other than
# "welcome" you should probably change this
RewriteRule ^(welcome(/index)?|index(\.php|html?)?)/?$ / [R=301,L]
RewriteRule ^(.*)/index/?$ $1 [L,R=301]

# Removes trailing slashes (prevents SEO duplicate content issues)
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.+)/$ $1 [R=301,L]

# Enforce www
# If you have subdomains, you can add them to 
# the list using the "|" (OR) regex operator
RewriteCond %{HTTP_HOST} !^(www|subdomain) [NC]
RewriteRule ^(.*)$ http://www.domain.com/$1 [R=301,L]

# Enforce no-www
#RewriteCond %{HTTP_HOST} ^www [NC]
#RewriteRule ^(.*)$ http://domain.com/$1 [L,R=301]

# Removes access to the system folder by users.
# Additionally this will allow you to create a System.php controller,
# previously this would not have been possible.
# 'system' can be replaced if you have renamed your system folder.
# RewriteCond %{REQUEST_URI} ^system.*
# RewriteRule ^(.*)$ /index.php/$1 [L]

# Checks to see if the user is attempting to access a valid file,
# such as an image or css document, if this isn't true it sends the
# request to index.php
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]

</IfModule>

<IfModule !mod_rewrite.c>

# Without mod_rewrite, route 404's to the front controller
ErrorDocument 404 /index.php

</IfModule>

@olegzhermal

This comment has been minimized.

Show comment
Hide comment
@olegzhermal

olegzhermal Aug 11, 2015

Worked. Thanks. RewriteBase is what I was looking for =))

Worked. Thanks. RewriteBase is what I was looking for =))

@teelake

This comment has been minimized.

Show comment
Hide comment
@teelake

teelake Sep 9, 2015

hi guys i am facing a similar error
my web app worked on my localhost but after uploading it on the webserver i cant access all pages except for the homepage(index page)
Each time i try to visit pages like about , contact i always get this error
ERROR 404 PAGE NOT FOUND
FILE NOT FOUND THIS SERVER
pls what is the way out. Thanks

teelake commented Sep 9, 2015

hi guys i am facing a similar error
my web app worked on my localhost but after uploading it on the webserver i cant access all pages except for the homepage(index page)
Each time i try to visit pages like about , contact i always get this error
ERROR 404 PAGE NOT FOUND
FILE NOT FOUND THIS SERVER
pls what is the way out. Thanks

@AyemyaThi

This comment has been minimized.

Show comment
Hide comment
@AyemyaThi

AyemyaThi Sep 22, 2015

I appreciated! It works. Thanks

I appreciated! It works. Thanks

@8ivek

This comment has been minimized.

Show comment
Hide comment
@8ivek

8ivek Nov 17, 2015

Thanks ^_^

8ivek commented Nov 17, 2015

Thanks ^_^

@Jagarm

This comment has been minimized.

Show comment
Hide comment
@Jagarm

Jagarm Dec 8, 2015

Thanks a lot, I have been trying to get it working on my site and this worked, right out of the box

Jagarm commented Dec 8, 2015

Thanks a lot, I have been trying to get it working on my site and this worked, right out of the box

@ahsankhan609

This comment has been minimized.

Show comment
Hide comment
@ahsankhan609

ahsankhan609 Jan 12, 2016

I have tried it a lot but it is not working for me. I have uploaded my Code Igniter Project on go Daddy... but still getting 404 Error Page...Please help me.

Even I have no sub folder. I am just uploading my project directly to public_html folder.

I have tried it a lot but it is not working for me. I have uploaded my Code Igniter Project on go Daddy... but still getting 404 Error Page...Please help me.

Even I have no sub folder. I am just uploading my project directly to public_html folder.

@denisdemais

This comment has been minimized.

Show comment
Hide comment
@denisdemais

denisdemais Mar 16, 2016

works fine!

works fine!

@ron4stoppable

This comment has been minimized.

Show comment
Hide comment
@ron4stoppable

ron4stoppable Apr 21, 2016

thanks, this worked flawlessly

thanks, this worked flawlessly

@jbmadking

This comment has been minimized.

Show comment
Hide comment
@jbmadking

jbmadking Apr 30, 2016

Worked perfectly. Thanks.

Worked perfectly. Thanks.

@lhesky

This comment has been minimized.

Show comment
Hide comment
@lhesky

lhesky May 6, 2016

hi! i am new to .htaccess anybody commments or recommendation on how do i start... im trying to my local host but not working so i try to join this group.tnx

lhesky commented May 6, 2016

hi! i am new to .htaccess anybody commments or recommendation on how do i start... im trying to my local host but not working so i try to join this group.tnx

@9-shen

This comment has been minimized.

Show comment
Hide comment
@9-shen

9-shen May 11, 2016

Thank u

9-shen commented May 11, 2016

Thank u

@lanoux22

This comment has been minimized.

Show comment
Hide comment
@lanoux22

lanoux22 Jun 16, 2016

and for escaping the wsdl from this rule how can i do? because after passing all my website in friendly url, the url of the web service given by NuSoap is unreachable

and for escaping the wsdl from this rule how can i do? because after passing all my website in friendly url, the url of the web service given by NuSoap is unreachable

@seymer

This comment has been minimized.

Show comment
Hide comment
@seymer

seymer Jun 17, 2016

RewriteEngine On Options +FollowSymlinks # !IMPORTANT! Set your RewriteBase here and don't forget trailing and leading # slashes. # If your page resides at # http://www.example.com/mypage/test1 # then use # RewriteBase /mypage/test1/ RewriteBase / RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^(.*)$ /index.php/home/?/$1 [L]

RewriteRule ^(.*)/welcome/$ $1/welcome/index [L]

seymer commented Jun 17, 2016

RewriteEngine On Options +FollowSymlinks # !IMPORTANT! Set your RewriteBase here and don't forget trailing and leading # slashes. # If your page resides at # http://www.example.com/mypage/test1 # then use # RewriteBase /mypage/test1/ RewriteBase / RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^(.*)$ /index.php/home/?/$1 [L]

RewriteRule ^(.*)/welcome/$ $1/welcome/index [L]

@Lorena93

This comment has been minimized.

Show comment
Hide comment
@Lorena93

Lorena93 Aug 12, 2016

My local project with Xampp 1.8.1 and codeigniter 3.0.6 is not running.
File htaccess:

`
RewriteEngine On

!IMPORTANT! Set your RewriteBase here and don't forget trailing and leading

slashes.

If your page resides at

http://www.example.com/mypage/test1

then use

RewriteBase /mypage/test1/

RewriteBase /codeigniter
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/$1 [L]

<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

`
File config:
$config['base_url'] = 'http://localhost/codeigniter';
$config['index_page'] = '';

$active_group = 'default';
$query_builder = TRUE;

File database:
$db['default'] = array(
'dsn' => '',
'hostname' => 'localhost',
'username' => 'root',
'password' => '',
'database' => 'sistemaderiego',
'dbdriver' => 'mysqli',
'dbprefix' => '',
'pconnect' => TRUE,
'db_debug' => (ENVIRONMENT !== 'production'),
'cache_on' => FALSE,
'cachedir' => '',
'char_set' => 'utf8',
'dbcollat' => 'utf8_general_ci',
'swap_pre' => '',
'encrypt' => FALSE,
'compress' => FALSE,
'stricton' => FALSE,
'failover' => array(),
'save_queries' => TRUE
);

File route:
$route['default_controller'] = 'Prueba';

any Help?

My local project with Xampp 1.8.1 and codeigniter 3.0.6 is not running.
File htaccess:

`
RewriteEngine On

!IMPORTANT! Set your RewriteBase here and don't forget trailing and leading

slashes.

If your page resides at

http://www.example.com/mypage/test1

then use

RewriteBase /mypage/test1/

RewriteBase /codeigniter
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/$1 [L]

<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

`
File config:
$config['base_url'] = 'http://localhost/codeigniter';
$config['index_page'] = '';

$active_group = 'default';
$query_builder = TRUE;

File database:
$db['default'] = array(
'dsn' => '',
'hostname' => 'localhost',
'username' => 'root',
'password' => '',
'database' => 'sistemaderiego',
'dbdriver' => 'mysqli',
'dbprefix' => '',
'pconnect' => TRUE,
'db_debug' => (ENVIRONMENT !== 'production'),
'cache_on' => FALSE,
'cachedir' => '',
'char_set' => 'utf8',
'dbcollat' => 'utf8_general_ci',
'swap_pre' => '',
'encrypt' => FALSE,
'compress' => FALSE,
'stricton' => FALSE,
'failover' => array(),
'save_queries' => TRUE
);

File route:
$route['default_controller'] = 'Prueba';

any Help?

@sawankjava

This comment has been minimized.

Show comment
Hide comment
@sawankjava

sawankjava Aug 30, 2016

You are great!!!!!!!!!

You are great!!!!!!!!!

@vrkansagara

This comment has been minimized.

Show comment
Hide comment
@vrkansagara

vrkansagara Sep 5, 2016

I were proposed a best solution for any project here.

I were proposed a best solution for any project here.

@gbrock

This comment has been minimized.

Show comment
Hide comment
@gbrock

gbrock Sep 16, 2016

@vrkansagara thanks for sharing, yours worked for me when the above did not.

gbrock commented Sep 16, 2016

@vrkansagara thanks for sharing, yours worked for me when the above did not.

@geovanent

This comment has been minimized.

Show comment
Hide comment
@geovanent

geovanent Oct 5, 2016

Muito Obrigado.
Brasil Representando...

Muito Obrigado.
Brasil Representando...

@ntaloventi

This comment has been minimized.

Show comment
Hide comment
@ntaloventi

ntaloventi Nov 28, 2016

works perfectly on shared hosting

works perfectly on shared hosting

@sumitnair26

This comment has been minimized.

Show comment
Hide comment
@sumitnair26

sumitnair26 Dec 9, 2016

after writing as RewriteRule ^(.*)$ index.php?/$1 [L] i am not able to enter base url $config['base_url'] = '/test/'; please help me out what changes should i do

after writing as RewriteRule ^(.*)$ index.php?/$1 [L] i am not able to enter base url $config['base_url'] = '/test/'; please help me out what changes should i do

@bill-goldberg

This comment has been minimized.

Show comment
Hide comment
@bill-goldberg

bill-goldberg Jan 22, 2017

I am just started to use codeigniter ...can anybody help me... i am working on a project developed using codeigniter and the project has a 'public' directory... how can i modify the .htaccess file so that i don't have to mention public directory in the link , e.g www.example.com/public

I am just started to use codeigniter ...can anybody help me... i am working on a project developed using codeigniter and the project has a 'public' directory... how can i modify the .htaccess file so that i don't have to mention public directory in the link , e.g www.example.com/public

@sourabhkshinde

This comment has been minimized.

Show comment
Hide comment
@sourabhkshinde

sourabhkshinde Jan 31, 2017

thanks you so much..

thanks you so much..

@calberto185

This comment has been minimized.

Show comment
Hide comment
@calberto185

calberto185 Feb 21, 2017

Hello one question!!!.
I am working with a template which is out system and application, and my login driver is login, where I load the view and also a method to validate login data. My question is why when I log in I do not redirect to the url with the controller and the method I already mentioned "velify". I was testing with the simplification of index.php in the .htaccess which if it works but when I put it does not testringa the folder where the template is housed it removes the styles of the view and in this case if I process the data when I log , But as you know this restricts me the template folder.
Note: for the login form I am using the codeigniter helper. This is my code view login:

<?= form_open('main/identify') ?> <div class="input-group"> <span class="input-group-addon" id="basic-addon1"> <i class="fa fa-user" aria-hidden="true"></i></span> <?= form_input($user) ?> </div> <div class="input-group"> <span class="input-group-addon" id="basic-addon2"> <i class="fa fa-key" aria-hidden="true"></i></span> <?= form_password($pass) ?> </div> <div class="text-center"> <?= form_input($submit) ?> </div> <?= form_close() ?>

This the code of the controller:

public function index(){
$this->load->view('main');
}
public function identify(){
$user = $this->input->post('username');
$pass = $this->input->post('password');
$result = $this->servicefire->Auth($user, $pass);
if ($result != null) {
header('location:'.base_url('admin/index'));
}else{
header('location:'.base_url());
}
}

This is my .htaccess:

RewriteEngine on
RewriteCond $1 !^(index.php|robots.txt|sitemap.xml|template)
RewriteRule ^(.*)$ index.php/$1 [L]

Hello one question!!!.
I am working with a template which is out system and application, and my login driver is login, where I load the view and also a method to validate login data. My question is why when I log in I do not redirect to the url with the controller and the method I already mentioned "velify". I was testing with the simplification of index.php in the .htaccess which if it works but when I put it does not testringa the folder where the template is housed it removes the styles of the view and in this case if I process the data when I log , But as you know this restricts me the template folder.
Note: for the login form I am using the codeigniter helper. This is my code view login:

<?= form_open('main/identify') ?> <div class="input-group"> <span class="input-group-addon" id="basic-addon1"> <i class="fa fa-user" aria-hidden="true"></i></span> <?= form_input($user) ?> </div> <div class="input-group"> <span class="input-group-addon" id="basic-addon2"> <i class="fa fa-key" aria-hidden="true"></i></span> <?= form_password($pass) ?> </div> <div class="text-center"> <?= form_input($submit) ?> </div> <?= form_close() ?>

This the code of the controller:

public function index(){
$this->load->view('main');
}
public function identify(){
$user = $this->input->post('username');
$pass = $this->input->post('password');
$result = $this->servicefire->Auth($user, $pass);
if ($result != null) {
header('location:'.base_url('admin/index'));
}else{
header('location:'.base_url());
}
}

This is my .htaccess:

RewriteEngine on
RewriteCond $1 !^(index.php|robots.txt|sitemap.xml|template)
RewriteRule ^(.*)$ index.php/$1 [L]

@arifurrahmanbd

This comment has been minimized.

Show comment
Hide comment
@arifurrahmanbd

arifurrahmanbd Mar 3, 2017

man it works

man it works

@anish137i

This comment has been minimized.

Show comment
Hide comment
@anish137i

anish137i May 6, 2017

Worked as expected for Godaddy

Worked as expected for Godaddy

@felipsmartins

This comment has been minimized.

Show comment
Hide comment
@felipsmartins

felipsmartins Aug 31, 2017

it works!

it works!

@geronimo794

This comment has been minimized.

Show comment
Hide comment
@geronimo794

geronimo794 Sep 2, 2017

Simple and work well

Simple and work well

@gandernirbhay

This comment has been minimized.

Show comment
Hide comment
@gandernirbhay

gandernirbhay Nov 1, 2017

it now work on window server please help.

it now work on window server please help.

@faizalfian

This comment has been minimized.

Show comment
Hide comment
@faizalfian

faizalfian Dec 28, 2017

Great ! Works perfect.

Great ! Works perfect.

@Baskargit

This comment has been minimized.

Show comment
Hide comment
@Baskargit

Baskargit Dec 30, 2017

Great ! Works Well

Great ! Works Well

@pba247

This comment has been minimized.

Show comment
Hide comment
@pba247

pba247 Feb 25, 2018

That works!

pba247 commented Feb 25, 2018

That works!

@guevaraj31

This comment has been minimized.

Show comment
Hide comment
@guevaraj31

guevaraj31 Mar 1, 2018

thanks man!

thanks man!

@xemuj

This comment has been minimized.

Show comment
Hide comment
@xemuj

xemuj Apr 2, 2018

Great ! Works Well

xemuj commented Apr 2, 2018

Great ! Works Well

@kingblizzy

This comment has been minimized.

Show comment
Hide comment
@kingblizzy

kingblizzy Apr 14, 2018

HI am Most greatful This Helped me out..... You are a good share mate.... Thanks.

HI am Most greatful This Helped me out..... You are a good share mate.... Thanks.

@malware-memez

This comment has been minimized.

Show comment
Hide comment
@malware-memez

malware-memez May 19, 2018

Thanks dude! this helps a lot.. it was 100% working for linux mint

Thanks dude! this helps a lot.. it was 100% working for linux mint

@xrb21

This comment has been minimized.

Show comment
Hide comment
@xrb21

xrb21 May 30, 2018

thanks, it's work perfectly

xrb21 commented May 30, 2018

thanks, it's work perfectly

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment