Reputation: 17
I have installed Apache 2.2, Php 5.4.5 and Mysql 5.5.27 on Windows 7 Operating System. My localhost location is G:/local_server. I have downloaded CodeIgniter_2.1.3 and extract to local_server and rename CodeIgniter. I crate a .htaccess file on CodeIgniter folder and Past this following code:
<IfModule mod_rewrite.c>
# Turn on URL rewriting
RewriteEngine On
# If your website begins from a folder e.g localhost/my_project then
# you have to change it to: RewriteBase /my_project/
# If your site begins from the root e.g. example.local/ then
# let it as it is
RewriteBase / CodeIgniter/
# Protect application and system files from being viewed when the index.php is missing
RewriteCond $1 ^(application|system|private|logs)
# Rewrite to index.php/access_denied/URL
RewriteRule ^(.*)$ index.php/access_denied/$1 [PT,L]
# Allow these directories and files to be displayed directly:
RewriteCond $1 ^(index\.php|robots\.txt|opensearch\.xml|favicon\.ico|assets|forums)
# No rewriting
RewriteRule ^(.*)$ - [PT,L]
# Rewrite to index.php/URL
RewriteRule ^(.*)$ index.php/$1 [PT,L]
</IfModule>
Then I changed following line from application/config/config.php
$config['index_page'] = 'index.php'; to $config['index_page'] = '';
$config['uri_protocol'] = 'AUTO'; to $config['uri_protocol'] = 'REQUEST_URI';
I have also delete # from Apache httpd.conf following line:
LoadModule rewrite_module modules/mod_rewrite.so
But still I can’t hide index.php file from CodeIgniter. :(
Help appreciated. :)
Upvotes: 0
Views: 17848
Reputation: 841
Here's my good 'ol trusty Codeigniter .htaccess file:
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond $1 !^(templates|plugins)
RewriteRule ^(.*)$ index.php/$1 [L]
Then rewrite your base to whatever you need, add the directories you need to access (I have templates and plugins there) and you should be good to go.
Of course, also make sure Apache has mod_rewrite enabled otherwise you won't get anywhere!
Upvotes: 8