views:

43

answers:

1

My current .htaccess:

<IfModule mod_rewrite.c>
# Turn on URL rewriting
RewriteEngine On

# Put your installation directory here:
# If your URL is www.example.com/, use /
# If your URL is www.example.com/kohana/, use /kohana/
RewriteBase /

# Do not enable rewriting for files or directories that exist
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d

# For reuests that are not actual files or directories,
# Rewrite to index.php/URL
RewriteRule ^(.*)$ index.php/$1 [PT,L]


</IfModule>

When someone navigates to:

http://mysite.com/demo/test

I want them to go to the actual folder. When someone navigates to:

http://mysite.com/demo I want them to go to index.php/$1.

How can I achieve this?

A: 

Your rule should work as it is only applied if the requested URL can not be mapped to an existing file (!-f) and not to an existing folder (!-d). So if /demo/test is an actual folder, the second condition (RewriteCond %{REQUEST_FILENAME} !-d) should fail. And if /demo is requested and is neither an existing regular file nor an existing folder it should be redirected to /index.php/demo.

Gumbo
To make demo/test a folder, I obviously have to make a folder called demo and create a folder test in it.
Alec Smart
@Alec Smart: Yes, `-f` and `-d` cause a real filesystem lookup.
Gumbo