EllisLab text mark
Advanced Search
     
how to remove index.php in my URL
Posted: 29 August 2007 07:53 AM   [ Ignore ]
Avatar
Joined: 2007-08-29
10 posts

Hi there,

I have tried a lot of different things to solve this issue but I didn’t find the good one.

here is my web site structure:

index.php
.htaccess
/site
    
/config
    
/controllers
    
/errors
    
/images
    
/javascript
    
/models
    
/views
    
/styles
/system
    
/cache
    
/CodeIgniter
    
/database
    
/helpers
    
/... 


I have just split off CI’s files from my web site to make it easier if I have to make it evolve. (not sure it is a good way to do that?!)

in my config file, I have got this :

/*
|--------------------------------------------------------------------------
| Base Site URL
|--------------------------------------------------------------------------
|
| URL to your CodeIgniter root. Typically this will be your base URL,
| WITH a trailing slash:
|
|    http://www.your-site.com/
|
*/
$config['base_url']    "http://myurl.com/";

/*
|--------------------------------------------------------------------------
| Index File
|--------------------------------------------------------------------------
|
| Typically this will be your index.php file, unless you've renamed it to
| something else. If you are using mod_rewrite to remove the page set this
| variable so that it is blank.
|
*/
$config['index_page'""


and in my .htaccess I have just copied and pasted this

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

from here : http://www.ellislab.com/codeigniter/user-guide/general/urls.html


I have seen in another topic that I may remove the

'/' 
before
RewriteRule ^(.*)$ /index.php/$1 [L] 

so I also tried with

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

but my web site still doesn’t work.

can you help me?

by the way, I am trying on me dev server but it was working on my computer.

thanks in advance

 
Posted: 29 August 2007 08:26 AM   [ Ignore ]   [ # 1 ]   [ Rating: 0 ]
Avatar
Joined: 2007-08-28
24 posts

Hi!

It is true, that leading slash shouldn’t be there, so it’s good that you removed it.

If you’d provide some more data of what exactly doesn’t work it’ll be easier to help.
However, this could possibly resolve your problem (as I’m using it, and it works for me):
replace the rewrite condition, provided in the example in the CI docs with these:

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond 
%{REQUEST_FILENAME} !-
 
Posted: 29 August 2007 08:33 AM   [ Ignore ]   [ # 2 ]   [ Rating: 0 ]
Avatar
Joined: 2007-08-29
10 posts

thanks! unfortunatly I have tried with your code
ie my .htaccess was:

RewriteEngine on
RewriteCond 
%{REQUEST_FILENAME} !-f
RewriteCond 
%{REQUEST_FILENAME} !-

but it doesn’t help.

I don’t even know how I can explain you better.

just, when i try this URL :

http://myurl.com/index.php/MainMenu/adminView
is works
but that one :
http://myurl.com/MainMenu/adminView
doesn’t

 
Posted: 29 August 2007 08:53 AM   [ Ignore ]   [ # 3 ]   [ Rating: 0 ]
Avatar
Joined: 2007-08-28
24 posts

Seems as if the problem lies somewhere else.

Try to describe how does exactly the page behaves itself, when you’re trying to enter it without index.php inthe URL.

Also recheck config and paths carefully (as you said it doesn’t work on the dev server) - I once forgot to change the database settings.

 
Posted: 29 August 2007 08:53 AM   [ Ignore ]   [ # 4 ]   [ Rating: 0 ]
Avatar
Joined: 2007-02-12
115 posts

http://ellislab.com/forums/viewthread/47023/

Elliot Haughin’s solution (.htaccess file in the directory of the project) worked for me,
it might work for you as well:

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

<IfModule !mod_rewrite.c>
  # If we don’t have mod_rewrite installed, all 404’s
  # can be sent to index.php, and everything works as normal.
  # Submitted by: ElliotHaughin

  ErrorDocument 404 /index.php
</IfModule>

 Signature 

—-
Moonbeetle web design & website redesign

 
Posted: 29 August 2007 09:10 AM   [ Ignore ]   [ # 5 ]   [ Rating: 0 ]
Avatar
Joined: 2007-08-29
10 posts
sparkling tux - 29 August 2007 12:53 PM

Seems as if the problem lies somewhere else.

Try to describe how does exactly the page behaves itself, when you’re trying to enter it without index.php inthe URL.

Also recheck config and paths carefully (as you said it doesn’t work on the dev server) - I once forgot to change the database settings.

well I have the problem on my whole web site (even if it is only few pages !!!)


when I try without the index.php in the URL, I have got this message :

Not Found

The requested URL 
/MainMenu/adminView was not found on this server.
Apache/2.0.54 (FedoraServer at becha.washrack.com Port 80 

By the way, it is not a pb with my DB.

 

joris, I have already seen this thread and tried this solution but it doesn’t work either/


any ideas?
thanks again guys wink

 
Posted: 29 August 2007 10:50 AM   [ Ignore ]   [ # 6 ]   [ Rating: 0 ]
Avatar
Joined: 2007-08-28
24 posts

It’s just a guess, but it may mean that Rewriting isn’t working - try to test some terribly simple rule, say everything goes to index.html.

And also I may suggest to try your URL *lowercase* (but for some reason I think it won’t help).

 
Posted: 30 August 2007 01:41 AM   [ Ignore ]   [ # 7 ]   [ Rating: 0 ]
Joined: 2007-08-29
3 posts

that could possible be you havent enabled the mod_rewrite function from apache server yet
http://codeignitercamp.blogspot.com/2007/08/my-issue-with-modrewrite.html
as a hint

 
Posted: 30 August 2007 07:13 AM   [ Ignore ]   [ # 8 ]   [ Rating: 0 ]
Avatar
Joined: 2007-08-29
10 posts
cloud226 - 30 August 2007 05:41 AM

that could possible be you havent enabled the mod_rewrite function from apache server yet
http://codeignitercamp.blogspot.com/2007/08/my-issue-with-modrewrite.html
as a hint

no I am afraid, the issue doesn’t come from here either…

 
Posted: 30 August 2007 08:07 AM   [ Ignore ]   [ # 9 ]   [ Rating: 0 ]
Avatar
Joined: 2007-08-29
10 posts

could you tell me how can I test my .htaccess file just to know if it works?
I have only this in it

ErrorDocument 404 /error.html 

error.html only contains

<body>
404 ERROR 
</body

but when I enter a wrong URL, I have got this :

404
Not Found

The requested URL 
/errdfgor.html was not found on this server.
Apache/2.0.54 (FedoraServer at becha.washrack.com Port 80 

is it me or what?

 
Posted: 31 August 2007 06:47 AM   [ Ignore ]   [ # 10 ]   [ Rating: 0 ]
Avatar
Joined: 2007-08-28
24 posts

I can advise to check the paths thoroughly - when Apache is unable to find custom error page it shows default one.
BWT, check whether you have real ‘MainMenu’ directory, placed next to the index.php. If true, the browser tries to fetch file from there instead of opening index.php.

 
Posted: 31 August 2007 06:59 AM   [ Ignore ]   [ # 11 ]   [ Rating: 0 ]
Avatar
Joined: 2007-08-29
10 posts

thanks everybody!

I didn’t yet find out the problem but I think it comes from my apache configuration (my .htaccess file is not recognize… )

I will get back to you we I will have solved this issue and if I still can’t remove the index.php from my URLs.

thanks again and have a good day.