I have an Apache web server that usually handles mod_rewrite fine. I have a directory called /communications/q/
and I want to rewrite any URI to insert "index.php" before the rest of the entered URI.
For example, /communications/q/something/else
should actually serve communications/q/index.php/something/else
. It's the standard PHP CodeIgniter setup.
I placed a .htaccess
file in the /q/ directory and put the following in it:
RewriteEngine On
RewriteCond $1 !^(index\.php|images|robots\.txt)
RewriteRule ^(.*)$ /index.php/$1 [L]
When I even try to go to /communications/q/, I get a 404 Not Found error. Which makes no sense at all because if I comment the .htaccess stuff out, I get the index.php page if I go to /communications/q/, but with the code, I get 404 Not Found.
Anyone spot what I'm doing wrong?
FYI I have a controller called hello, so technically /communications/q/hello should work, but it's a 404, also. But with .htaccess commented out, /communications/q/index.php/hello works fine.
..
==== ADDED NOTE #1 ====
Using CodeIgniter, I should be able to call controllers and functions using the URI structure. So I have a controller called welcome
, actually, and then a function called index()
which is the default, and a function called hello()
.
The way CI works, I would write /communications/q/index.php/welcome
and I would get the output of the index()
function from the welcome
controller. And in fact, this works perfectly right now.
Unfortunately, having that weird index.php
in the URI is unwieldy and unnecessary, so CI suggests using .htaccess to allow the URI to omit that section of the URI and silently reenter it in the background, using mod_rewrite.
When I add the RewriteRule above, however, it doesn't work. So:
/controller/q/welcome
returns a 404 error when it should return exactly the same thing as /controller/q/index.php/welcome
. That's the problem. Shouldn't the RewriteRule above make that work?
..