Reputation: 1816
I used the code below to remove index.php in codeigniter in my .htaccess file. But the thing that I am confused is where should i use the file. should i use it inside my www folder outside the application or inside the application.
I used it in all places, and it worked but it is messing up with my css or say base folders. How can I overcome the problem. Should i use the html base tag?
RewriteEngine on
RewriteCond $1 !^(index\.php|images|robots\.txt)
RewriteRule ^(.*)$ /index.php/$1 [L]
EDIT
my folder structure is
basefolder
-application
-css
-js
-images
-system
.htaccess
index.php
Upvotes: 0
Views: 196
Reputation: 1570
copy and paste below code in .htaccess file
Options +FollowSymLinks
RewriteEngine On
Options -Indexes
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /index.php\ HTTP/ RewriteRule ^index.php$ http://www.yoursite.com/ [R=301,L]
Upvotes: 0
Reputation: 49873
use this
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /index.php/$1 [L]
if doesn't works check if you enabled mod_rewirte
in phpinfo();
if it doesn't works yet, try to change the $config['uri_protocol']='AUTO'
to one of the listed inside application/config/config.php
file on line 40/54:
|
| 'AUTO' Default - auto detects
| 'PATH_INFO' Uses the PATH_INFO
| 'QUERY_STRING' Uses the QUERY_STRING
| 'REQUEST_URI' Uses the REQUEST_URI
| 'ORIG_PATH_INFO' Uses the ORIG_PATH_INFO
|
*/
$config['uri_protocol'] = 'AUTO';
sometimes i used : REQUEST_URI
instead of AUTO
Upvotes: 1
Reputation: 401
My solution, CI system move up (not public from the web), applications are public, .htaccess
for each subdomains (in root directory), but its depends on your structure (many solutions exists)
RewriteBase /
RewriteEngine on
RewriteCond $1 !^(index\.php|images|css|js|robots\.txt|favicon\.ico)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?$1 [L]
Upvotes: 0
Reputation: 15639
You can add an RewriteCondition which excludes all exisiting files:
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
Upvotes: 2
Reputation: 18843
RewriteEngine on
RewriteCond $1 !^(index\.php|css|js|images|robots\.txt)
RewriteRule ^(.*)$ /index.php/$1 [L]
This assumes css is in the same directory as index.php, etc. This rule depends on your file structure. If you update your question with an example of your directory tree I can modify the rules.
There should be no other configuration needed for this since you mention it works but just messes things up.
It should be noted, this one pasted is the only thing in my CI htaccess file and mine works fine.
Also, see Will's comment. My config url suffix is always ""
Upvotes: 0