Welcome Guest, Not a member yet? Register   Sign In
how to remove index.php in my URL
#1

[eluser]ppeemm[/eluser]
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:

Code:
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 :

Code:
/*
|--------------------------------------------------------------------------
| 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
Code:
RewriteEngine on
RewriteCond $1 !^(index\.php|images|robots\.txt)
RewriteRule ^(.*)$ /index.php/$1 [L]

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


I have seen in another topic that I may remove the
Code:
'/'
before
Code:
RewriteRule ^(.*)$ /index.php/$1 [L]

so I also tried with
Code:
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
#2

[eluser]sparkling tux[/eluser]
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:
Code:
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
#3

[eluser]ppeemm[/eluser]
thanks! unfortunatly I have tried with your code
ie my .htaccess was:
Code:
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
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
#4

[eluser]sparkling tux[/eluser]
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.
#5

[eluser]moonbeetle[/eluser]
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:

Quote:<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>
#6

[eluser]ppeemm[/eluser]
[quote author="sparkling tux" date="1188406390"]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.[/quote]

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 :

Code:
Not Found

The requested URL /MainMenu/adminView was not found on this server.
Apache/2.0.54 (Fedora) Server 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
#7

[eluser]sparkling tux[/eluser]
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).
#8

[eluser]cloud226[/eluser]
that could possible be you havent enabled the mod_rewrite function from apache server yet
http://codeignitercamp.blogspot.com/2007...write.html
as a hint
#9

[eluser]ppeemm[/eluser]
[quote author="cloud226" date="1188466867"]that could possible be you havent enabled the mod_rewrite function from apache server yet
http://codeignitercamp.blogspot.com/2007...write.html
as a hint[/quote]

no I am afraid, the issue doesn't come from here either...
#10

[eluser]ppeemm[/eluser]
could you tell me how can I test my .htaccess file just to know if it works?
I have only this in it
Code:
ErrorDocument 404 /error.html
error.html only contains
Code:
&lt;body&gt;
404 ERROR
&lt;/body&gt;
but when I enter a wrong URL, I have got this :
Code:
404
Not Found

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

is it me or what?




Theme © iAndrew 2016 - Forum software by © MyBB