I can't get my htaccess file to work correctly. I want to remove index.php from the url's, but the htaccess code from the guide messes everything up. How do I do this?

[eluser]Stefano G[/eluser]
Hi, there are many useful posts about this topic but... :p

in the
file make sure that the index page is set to blank

$config['index_page'] = "";

this is as important as the .htaccess file.

Then you could use this file as your .htaccess file:

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

Last but not least, are you sure that mod_rewrite is available on your provider's apache server? and are you sure that in YOUR localhost apache server is mod_rewrite enabled?

If you installed XAMPP or similar make sure that everything's ok on that side as well!

There is a method for checking that mod_rewrite is enabled: googling for "test if mod_rewrite enabled" I happened to open this page.



I fixed this issue by placing the .htaccess file in the base folder; the same one as index.php appears in and just using the basic rewrite code provided by the user guide.

Super .htaccess

[eluser]Stefano G[/eluser]
[quote author="Bursh" date="1219371604"]I fixed this issue by placing the .htaccess file in the base folder; the same one as index.php appears in and just using the basic rewrite code provided by the user guide.[/quote]

...oops this is something I forgot to mention but I assumed it was obvious Wink

I was looking around for same topic, and found your discussion .I got same problem but the solution didnt make any difference. It gives following error message

Quote:500 Internal Server Error
The server encountered an internal error or misconfiguration and was unable to complete your request.

Please contact the server administrator, [email protected] and inform them of the time the error occurred, and anything you might have done that may have caused the error.

More information about this error may be available in the server error log.

I have removed index from other site, which is not based code igniter, and it worked okay. Proves that, mod_rewriting is enabled. I have placed the file on same level where index.php resides.

Need suggestions. Thank you

[eluser]Stefano G[/eluser]
The Internal Server error is probably due either to a wrong configuration file (did you modify your httpd.conf recently?) or an error in your .htaccess file.

The config file I have enclosed is suitable when you have codeigniter index.php file and .htaccess at the ROOT level of your server.

if you have several projects on your htdocs folder

htdocs <--- root level
  +---- projectone
  +---- another project
  +---- mycodeigniterproject
              +-- system
              +-- .htaccess
              +-- index.php

then you should modify your .htacess as follows:

RewriteRule ^(.*)$ /mycodeigniterproject/index.php?/$1 [L]


RewriteBase /mycodeigniterproject
RewriteRule ^(.*)$ index.php?/$1 [L]             <--- WITHOUT leading slash!!!

also remember to modify the

as follows:

$config['base_url']= "http://localhost/mycodeigniterproject/";  <--- WITH a trailing slash!!!
$config['index_page'] = "";

Hope it helps!


Thanks for the guidance. Nope, that didnt resolve it. But removed the error message. Now shows Error 404 "Page not found".

There is something missing in url, as its

this => "http://localhost/Linked//welcome/skill" instead of being
this => "http://localhost/Linked/welcome/skill"

[eluser]Stefano G[/eluser]
Have a look at your
how does the default_cotroller looks like?

mine is :

$route['default_controller'] = "start"; <--- WITHOUT slashes!!!

so either if I type http://localhost/citestapp/start or http://localhost/citestapp/ I am redirected to the index method of my Start.php controller

no problem with default controller as defined

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

The .htaccess file include this

RewriteRule ^(.*)$/Linked/index.php?/$1 [L]

Havent add RewriteEngine on, as when I include the statment, html error 500 occurs, as mentioned before.

Is there a way , I can confirm that apache is accepting htaccess directives and some good resource, where I could learn htaccess coding.

Thanks for the guidance.

Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  

  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2021 MyBB Group.