0
RewriteEngine On
RewriteBase /path/learn_ci

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /path/learn_ci/$1 [L]

Above my .htaccess file how to configure it.

Mayur Patel
  • 235
  • 1
  • 12

3 Answers3

1

On your .htaccess file put below code.

RewriteEngine On
RewriteBase /path/learn_ci
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond $1 !^(index\.php|css|asset|images|robots\.txt)
RewriteRule ^(.*)$ index.php/$1 [L]

On your application/config/config.php Put below code

$config['base_url'] = 'http://yourdomain.com/';
$config['index_page'] = '';

It will be work for you.

Enjoy...!!! :)

Kishan Patel
  • 1,308
  • 9
  • 23
0

This is what I've been using on most of my CodeIgniter projects, and never had issues.

You need to adjust your RewriteBase. It starts from the root of the web server /www/your_project would be changed to /your_project/ in the htaccess file.

Also, make sure you have mod_rewrite enabled.

How to enable mod_rewrite for Apache 2.2

CodeIgniter htaccess and URL rewrite issues

In addition, you need to remove the index.php from $config['index_page'] = 'index.php' located in config.php in your CodeIgniter installation.

<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /your_project/

    #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]

    #When your application folder isn't in the system folder
    #This snippet prevents user access to the application folder
    #Submitted by: Fabdrol
    #Rename 'application' to your applications folder name.
    RewriteCond %{REQUEST_URI} ^application.*
    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 $1 !^(index\.php|img|font|css|temp|js|robots\.txt|favicon\.ico)
    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>
Community
  • 1
  • 1
Marko Aleksić
  • 1,541
  • 1
  • 18
  • 23
0

this should be your htaccess file on the root folder of your project

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase / yourproject


#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]

#When your application folder isn't in the system folder
#This snippet prevents user access to the application folder
#Submitted by: Fabdrol
#Rename 'application' to your applications folder name.
RewriteCond %{REQUEST_URI} ^application.*
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>
# 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>

and you can remove the index.php from the config.php as: $config['index_page'] = '';

Robz
  • 1,080
  • 3
  • 14
  • 35