CodeIgniter Forums
Removing the index.php file - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived General Discussion (https://forum.codeigniter.com/forumdisplay.php?fid=21)
+--- Thread: Removing the index.php file (/showthread.php?tid=12297)

Pages: 1 2


Removing the index.php file - El Forum - 10-15-2008

[eluser]asim111[/eluser]
By using that code
homepage is working and not adding index.php automatically
Code:
http://www.live-site-url.co.uk/
working with
Code:
http://www.live-site-url.co.uk/index.php/used-cars/
but still error with
Code:
http://www.live-site-url.co.uk/used-cars/
The error is:
Code:
Page not found
The page you are looking for might have been removed,
had its name changed, or is temporarily unavailable.
This is server's 404 page not found error not by CI

Anyways,
i goning to try something different
i am not good in .httaccess but

how we can convert index.php to directory style url ?
Code:
http://www.live-site-url.co.uk/index.php/used-cars/
Convert into
Code:
http://www.live-site-url.co.uk/index/used-cars/

if trick works then i will rename index.php to cars-for-sales.php
and url will be
Code:
http://www.live-site-url.co.uk/cars-for-sales/used-cars/


what you say??? ;-)


Removing the index.php file - El Forum - 10-15-2008

[eluser]Flemming[/eluser]
it seems that your mod_rewrite is not working at all! because :
Code:
http://www.live-site-url.co.uk/
works - as you would expect, it will default to index.php if you don't put it in the url.
Code:
http://www.live-site-url.co.uk/index.php/used-cars/
works - because it has index.php in the url
Code:
http://www.live-site-url.co.uk/used-cars/
fails because it is not including index.php via mod_rewrite

If i was you I would try doing some basic mod_rewrite things separate from CI to establish that you can actually use mod_rewrite ... if problems continue I would speak to your host!

Hope that helps?


Removing the index.php file - El Forum - 10-20-2008

[eluser]asim111[/eluser]
It is not working as well
Code:
RewriteRule ^/(.*)$ /index.php/$1

Anyways we can now replace index.php with anything but can't remove...

Code:
RewriteRule ^/(.*)$ /index.php/$1

CODE Replaced With
Code:
RewriteRule ^cars(.*)$ index.php?$1 [L]

Now i can access my sites like
Code:
http://www.live-site-url.co.uk/cars/used-cars/

i replaced index.php with CARS. but not working like
Code:
RewriteRule ^(.*)$ index.php?$1 [L]



Removing the index.php file - El Forum - 10-20-2008

[eluser]Flemming[/eluser]
what happens if you put this as your first rule:
Code:
RewriteRule ^/(.*)$ http://www.google.co.uk [L]

now whatever address you try at your site should take you to google.co.uk instead. If this does not happen then you know your mod_rewrite is being ignored.

Let me know what happens!


Removing the index.php file - El Forum - 10-20-2008

[eluser]asim111[/eluser]
By using this rule
mysite is redirecting to google.co.uk


Removing the index.php file - El Forum - 10-20-2008

[eluser]Flemming[/eluser]
great - so that means your mod_rewrite does work, you just need to fine-tune the rules!

This one SHOULD work:

Code:
RewriteRule ^/(.*)$ /index.php/$1

so that if you visit

Code:
http://www.live-site-url.co.uk/used-cars/

it should be re-written to

Code:
http://www.live-site-url.co.uk/index.php/used-cars/

(remember, you won't see that in the address bar - it will still read

Code:
http://www.live-site-url.co.uk/used-cars/

if you feel like you're going round in circles then please search these forums for mod_rewrite examples and try every combination you can. Eventually you will find success!

what happens if you try

Code:
RewriteRule ^/(.*)$ /index.php/$1 [R]

this should FORCE a redirect, so you will see the new address in your address bar, i.e.

Code:
http://www.live-site-url.co.uk/index.php/used-cars/



Removing the index.php file - El Forum - 10-20-2008

[eluser]Yash[/eluser]
Try this


Code:
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]



Removing the index.php file - El Forum - 10-24-2008

[eluser]Unknown[/eluser]
Apache 2.x is different. Try this

AcceptPathInfo on

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