views:

30

answers:

2

I'm using Mod Rewrite to remove index.php. I do not want to use queries. I want foo.com/bar to be interpreted as foo.com/index.php/bar.

It does this fine, but gives me Not Found error. The requested URL /home/foo/www/index.php/bar was not found on this server.

Why!!

A: 

Update

I think I just figured out what you are wanting to do. You see, you can pass queries behind the scenes, but you cannot pass what you are suggesting behind the scenes. You have to do an actual redirect. Something like this (The important part is the R):

RewriteRule ^bar$ index.php/bar [NC,QSA,R]

This forces a redirect to your page using the new special path. Is that what you wanted?

Original Answer

You cannot pass a path to a PHP page like that as it will be interpreted as part of a path. Chances are, your file is on a Linux/Unix machine where a directory can be named with a . in it. Sorry, but you will have to use a query string:

RewriteBase /
RewriteRule ^bar$ index.php?page=bar [NC,QSA]

Or updated:

RewriteBase /
RewriteRule ^bar$ index.php?/bar [NC,QSA]

I also think the last few versions of windows support . in directories as well, but I am not sure.

Doug Neiner
Yes, Windows will allow `.` in directories.
John Feminella
I'm looking for a segmented approach, instead of by query. Code Igniter uses it, I believe. Unless they're just sneaky about it.http://bit.ly/bGdA8n
Luke Burns
@Luke, read through that whole link you shared. You'll see their 'Online Solution' is actually `index.php?/bar` which still uses the query string, just without a variable name.
Doug Neiner
Ah! Fabulous! That's it. Thank you Doug!
Luke Burns
@Luke Burns No problem man, sorry I misunderstood what you wanted at first! Good luck on your project!
Doug Neiner
A: 

index.php is almost certainly a file, not a directory, unless you (bizarrely) have a directory called index.php. Apache is correctly complaining that there is no such directory.

You probably meant to do something like index.php?page=bar. Adjust your .htaccess accordingly.

John Feminella
Oh, it's treating it like a directory?What can I do if I don't want to use queries?
Luke Burns