EllisLab text mark
Advanced Search
     
how do you really remove index.php
Posted: 02 May 2010 03:42 PM
Joined: 2008-02-26
10 posts

Okay so I’ve been at it for several days now and I just can’t seem to remove the index.php from my urls.

• mod_rewrite is enabled
• apache has been configured to allow .htaccess overrides (other 301 redirects are working)
• $config[‘index_page’] = “”;
• $config[‘uri_protocol’] = “AUTO”; (I have tried with other settings)
• I followed these instructions to setup my .htaccess file.

I am assuming that my issue is a path issue. I have the default CI install inside a project folder so my structure looks like this:
- localhost
    - freelance
      - ps
          .htaccess
          index.php
          - system

any insight would be helpful, thank you!

 
Posted: 02 May 2010 05:25 PM   [ # 1 ]   [ Rating: 0 ]
Joined: 2006-08-26
661 posts

1. You might need to set the rewrite base

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

2. You might need to adapt the rewrite condition, in the CI example everything that is not named index.php, images or robots.txt is redirected to to the application, so if You have say a folder assets instead of images Your condition is

# ...
RewriteCond $!^(index\.php|assets|robots\.txt)
# ... 
 Signature 

Die Wirklichkeit ist das, was übrig bleibt, wenn man aufgehört hat, daran zu glauben.

 
Posted: 02 May 2010 07:28 PM   [ # 2 ]   [ Rating: 0 ]
Joined: 2008-02-26
10 posts

Thanks for you reply tomcode. I had tried using the rewrite base before with no luck and unfortunately that is still the case. I get no error… it just doesn’t work. Thanks for the tip in #2 though. I’m not trying to access anything special I just want my url to look like: http://localhost/freelance/ps/home/ instead of: http://localhost/freelance/ps/index.php/home/

this is so frustrating, I’ve been trying to get this to work for a couple days now and the mod_rewrite docs are a little over my head. seems like it should be easy.

my current (non-working) file looks like this:

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

Anything that I might be missing?

 
Posted: 02 May 2010 07:38 PM   [ # 3 ]   [ Rating: 0 ]
Joined: 2006-08-26
661 posts

just to make sure, http://localhost/freelance/ps/index.php/home/without use of .htaccess works ?

Then, what error do You get when using the .htaccess ?

 Signature 

Die Wirklichkeit ist das, was übrig bleibt, wenn man aufgehört hat, daran zu glauben.

 
Posted: 02 May 2010 09:20 PM   [ # 4 ]   [ Rating: 0 ]
Joined: 2008-02-26
10 posts

http://localhost/freelance/ps/index.php/home/
works with or without the .htaccess file

with .htaccess
http://localhost/freelance/ps/home/
throws a 404 (The requested URL /index.php/home was not found on this server.)

without .htaccess
http://localhost/freelance/ps/home
throws a 404 (The requested URL /freelance/ps/home was not found on this server.)

http://localhost/freelance/ps/index.php and http://localhost/freelance/ps/ both seem to work and are pointing to my default controller.

 
Posted: 02 May 2010 11:44 PM   [ # 5 ]   [ Rating: 0 ]
Joined: 2010-05-02
2 posts

这个原理我不懂...嘿嘿

 
Posted: 03 May 2010 04:08 AM   [ # 6 ]   [ Rating: 0 ]
Joined: 2006-08-26
661 posts

Your Rewrite script works, but it points to http://localhost/index.php/home

Try without the line RewriteBase (haven’t You started like that ?)

Do You use any symbolic links ? Try using the line

Options +FollowSymLinks 

If it’s not one of the above I cannot think of something else.

 Signature 

Die Wirklichkeit ist das, was übrig bleibt, wenn man aufgehört hat, daran zu glauben.

 
Posted: 03 May 2010 10:30 AM   [ # 7 ]   [ Rating: 0 ]
Avatar
Joined: 2009-12-08
1804 posts

Don’t remove rewritebase, remove the leading slash in the rewriterule. The example htaccess assumes CI is installed in webroot (hence the lack of a rewritebase).

RewriteEngine on
RewriteBase 
/freelance/ps/
RewriteCond $!^(index\.php|images|robots\.txt)
RewriteRule ^(.*)$ index.php/$1 [PT,L] 
 Signature 

@basdflasjk | BitAuth: Authentication and Role-based Permissions | Session Library Replacement


Please read the User Guide! (Upgrading from a previous version?)

 
Posted: 03 May 2010 11:03 AM   [ # 8 ]   [ Rating: 0 ]
Joined: 2006-08-26
661 posts

Thanks noctrum, yeah, that should it be.

 Signature 

Die Wirklichkeit ist das, was übrig bleibt, wenn man aufgehört hat, daran zu glauben.

 
Posted: 03 May 2010 11:07 AM   [ # 9 ]   [ Rating: 0 ]
Joined: 2008-02-26
10 posts

YES!! it was the leading slash. A big thank you to the both of you.  grin

 
Posted: 03 May 2010 11:41 AM   [ # 10 ]   [ Rating: 0 ]
Joined: 2009-01-20
61 posts

First time before using Tank Auth I found it in Codeigniter Wiki list. At the moment Tank Auth is removed from list http://codeigniter.com/wiki/Category:Contributions::Libraries::Authentication/

Is it end of Support Tank Auth by Gromozeka or something else?

 
Posted: 08 September 2010 04:36 AM   [ # 11 ]   [ Rating: 0 ]
Avatar
Joined: 2010-08-05
11 posts
bpdp - 03 May 2010 03:07 PM

YES!! it was the leading slash. A big thank you to the both of you.  grin

I tried this all. but found nothing working.
my codeigniter application is in /var/www/healthengine/employee folder.

Thanks in advance.

 Signature 

Thanks & regards
siDh!

 
Posted: 08 September 2010 07:57 AM   [ # 12 ]   [ Rating: 0 ]
Joined: 2010-09-08
9 posts

I used these in my htaccess.

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


it should work. actually this is the same thing used by the previous posters