0

i have installed codeigniter and i want to remove the index.php from url when i access localhost/aplication/index.php. i have set uncomment mod_rewrite.so from httpd.conf en this is my .htaccess file :

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

its succes when i acces url from localhost/aplication/index.php/data/users/12 but not with this url localhost/aplication/data/users/12.

how can i fix this??

1
  • 2
    Does your virtualhost config allow overrides? Commented Sep 21, 2012 at 16:43

3 Answers 3

1

Try to follow this page about codeignitor pretty urls. Your rules look correct, but I'm terrible with regex.

Some things to look into would be checking if mod_rewrite is available by using phpinfo();. Also step three in that link talks about enabling mod_rewrite using a2enmod. And make sure you restart Apache.

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

Comments

0

check your config file there should be a line that says:

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

You can either set this variable to just '' or you can comment this line out completely, either way it is part of the process of removing the index.php from your codeigniter urls.

Comments

0

this is how you remove the index.php:

htaccess file in the root folder:

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

for managing some static pages like: example.com/about , example.com/contact, example.com/terms etc

got to config routes file and edit:

//the controller that will be when it is exampl.com
$route['default_controller'] = 'YOUR_MAIN_CONTROLLER_NAME_HERE';
//I creted this for pages that are created dynamically or for displaying error when I want
$route['404_override'] = 'friendlyPages';

Comments

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.