0

I want to remove index.php from codeigniter url my current configurations I tried so far with zero results are

folder structure: xampp\htdocs\Codeigniter\application\controllers\olx\olx.php xampp\htdocs\Codeigniter\application\views\olx\frmSignup

my HTACCESS file on the location xampp\htdocs\Codeigniter.HTACCESS with the following contents nothing else in .HTACCESS file for me

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

mod_rewrite is enabled checked using phpinfo();

following changes made to config.php file

$config['base_url'] = 'http://mypc/olx';
$config['index_page'] = '';

when try to access this url

http://mypc/codeigniter/olx/frmSignup i get 404 error

changes made to routes.php are

$route['default_controller'] = 'olx';
$route['olx/frmSignup']  = 'olx/frmSignup';

please help I want to access my app without index.php. i am working on localhost with Windows7

5 Answers 5

1

Change AllowOverride None to AllowOverride All in my virtual host file at /etc/apache2/sites-available/000-default.conf in ubuntu Change AllowOverride None to AllowOverride All in my virtual host file at /etc/apache2/sites-available/default.conf in windows

<VirtualHost *:80>
    ServerAdmin webmaster@localhost

    DocumentRoot /var/www
    <Directory />
            Options FollowSymLinks
            AllowOverride All    <---- replace None with All
    </Directory>
    <Directory /var/www >
            Options Indexes FollowSymLinks MultiViews
            AllowOverride All   <---  replace None with All
            Order allow,deny
            allow from all
    </Directory>
....

Then put this code in .htaccess file in root folder in codeigniter

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

It will definately work.

Sign up to request clarification or add additional context in comments.

Comments

0

From http://ellislab.com/codeigniter%20/user-guide/general/urls.html - Try

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

Comments

0

after all said by friends, you have to do another thing (I think you are doing it on localhost):

First, double check the suggestions: then go to windows tray, right click on WAMP icon, and then click on it , go to Apache menu, and then to modules and then check for rewrite_module to see if it is checked or not, and click on it if you find it unchecked (means disabled) to enable it. Now try again and report it...

1 Comment

yes I've double checked all suggestions, working on localhost and using xampp not wamp and checked in loaded modules for mod_rewirte its there please suggest am stuck in this stupid problem
0

You just have to create .htaccess file on the root application folder or edit it if you already have. The following .htaccess file works for me.

.htaccess

# BEGIN ci
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]

RewriteCond ${REQUEST_URI} ^.+$
RewriteCond %{REQUEST_FILENAME} \.(gif|jpe?g|png|js|css|swf|php|ico|txt|pdf|xml)$
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>

Comments

0
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /Codeigniter

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

so not olx as it's a controller and not a folder

in config

$config['base_url'] = '';
$config['index_page'] = '';

in route

$route['default_controller'] = "olx";

and move your D:\xampp\htdocs\Codeigniter\application\controllers\olx\olx.php to D:\xampp\htdocs\Codeigniter\application\controllers\olx.php

and olx should look like

class olx extends CI_Controller {


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

 }


public function index()
{

    echo "test";
    // or $this->load->view('olx/overview.php', $data);

}

}

and try localhost/codeigniter/ or localhost/codeigniter/olx

13 Comments

I tried your .htaccess file and tried to access the following url with same 404 result localhost/olx/frmSignup
what is your localhost, how do access a html file in that directory? think the url is the problem and the config as those are different now, not the htaccess.
localhost/codeigniter/test.html further if its developed in CI files will be placed in controller and views directory respectivly and than index.php will be involved in the url I want to access the files placed in views folder like this localhost/olx/frmSignup
I tried ur updated suggestion but still getting 404 let me tell u my exact folder structure again Codeigniter\application\controller\olx\olx.php Codeigniter\application\views\olx\frmSignup.php and for ur information frmSignup is view not controller. I have applied all the settings u mentioned but no result
steps: 1/ know where your localhost is directed to with xampp (use an index.html) 2/ copy the index.html to a folder named olx and check if you can access the html with localhost/olx 3) copy codedigniter there and use an echo in your controller to test. the folder application and index.php should be in your olx folder (not olx/codeigniter/application)
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.