Welcome Guest, Not a member yet? Register   Sign In
Get rid of index.php from url
#1

[eluser]barisv[/eluser]
Hi,

I read lots of document and successed to remove index.php from url on local computer. But when I sent the folders to the server, it doesnt working properly. It always redirect to index.php. What can be the problem ?

Code:
[b]The Controller
[/b]

<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class Site extends CI_Controller {

    function __construct()
    {
        parent::__construct();
    }

    function index()
    {
        echo "Hello world 61";
    }
    
    
    function blabla()
    {
            
        echo "blabla blabla";        
    }
    
    
    
}

?>


config.php
Code:
$config['base_url']    = 'http://www.mywebaddress.com/';

$config['index_page'] = '';


.htaccess



Code:
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]

    ErrorDocument 404 /index.php

routes.php

Code:
$route['default_controller'] = "site";
$route['404_override'] = '';

When I type

http://mywebadress.com/site
It opens index.php page

When I type
http://mywebadress.com/site/blabla
It also opens index.php page

Not the function that should be echo out "blabla blabla"


Thanks in advance.
#2

[eluser]barisv[/eluser]
This htaccess works well on my server. Problem was solved.

Code:
DirectoryIndex index.php

<IfModule mod_rewrite.c>

  RewriteEngine on
  RewriteBase /
  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteCond %{REQUEST_FILENAME} !-d
  RewriteRule ^(.*)$ index.php/$1 [L,QSA]
  
</IfModule>

<IfModule !mod_rewrite.c>
  ErrorDocument 404 index.php
</IfModule>




Theme © iAndrew 2016 - Forum software by © MyBB