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

Hey,

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:

http://workspace/MVC/

So it Rewrite the URL to:
http://workspace/MVC/index

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,
/index/page
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]
</IfModule>

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]

Regards,

DK

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
http://workspace/MVC/controller/function/value

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

Heya,

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?