Search code examples
.htaccesscodeigniterroutessubdirectory

Codeigniter 2.1.4 installation in sub directory


I have successfully installed CI in the root directory many times, but now I have been forced to install CI in https://mydomain.com/mvc

There exists one controller "Login" with one action "index"

The .htaccess file looks like:

Options +FollowSymLinks  
RewriteEngine on  
RewriteBase /mvc  
RewriteRule ^(.*)$ index.php?/$1 [L]  

In config/config.php

$config['base_url'] = 'https://mydomain.com/mvc/';  
$config['index_page'] = '';  

My routes look like:

$route['default_controller'] = "login";  
$route['login'] = "login/index";  
$route['404_override'] = '';  

mod_rewrite is enabled
https://mydomain.com/mvc gives a 404
https://mydomain.com/mvc/login gives a 404
What do I miss?


Solution

  • What´s your hosting? if is hostgator you need add your user.

    Try this

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

    if your hosting is hostgator you need add you name user, for example

    RewriteEngine On
    RewriteBase /~<name_user>/%{HTTP_HOST} <or> <your folder>
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.*)$ /~<name_user>/%{HTTP_HOST} <or> <your folder>/index.php/$1 [L]