.htaccess, Probably easy but I can't find out how!


I have searched for this and can’t get on the right track, I don’t know if I’m ever going to understand .htaccess!

This seems easy but I can’t get it right! I would like to have when you go to this URL:


So it Rewrite the URL to:

I have tried DirectoryIndex index.php, but you see it has to actually load index.php in the first place and then PHP handles other things.

I would just like it to be rewritten to /MVC/index only when nothing is after /MVC/.

The reason I want to do this is because I don’t want to have to write two sets of urls,
or /page/

based on whether or not they have index/ loaded or not in the URI.
Thanks for your time.

Thanks I will try this,
Haha I hadn’t even considered that wasting resources thanks!

If you send it to /index it’s going to be looking in the directory index, not the file index. I’m not sure what the controller stuff you’re talking about is.

Okay, you’re correct about DirectoryIndex serving the actual page selected from the list of files for the DirectoryIndex.

<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^(.*)$ index.php?url=$1 [QSA,L]

ARGH! Are you a webmaster or not? Okay, asking Apache to use <IfModule> for EvERY request is extremely wasteful! REMOVE THAT NONSENSE!

Then, before the first RewriteCond, insert

RewriteRule ^MVC/$ MVC/index [R=301,L]



That doesn’t help that redirecting to /index will look for the directory index.

Tell me this, what exactly (in detail) are you trying to do, and why?

Well I already have this,
and anything after index.php loads a controller, but the URL looks like

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php?url=$1 [QSA,L]


just /index

Because the actual index.php loads, Then /index is a controller,
but I want it to show /index (because thats a controller name)

Do you want it /index or /index.php?