I'm trying to direct all requests in a certain directory (/dir/) except for that directory's index (/dir/index.php) to a certain script (/dir/item.php). This sounds very simple even to me, but I've spent hours trying at least 20 different methods with no success.
I want to solve this with a .htaccess file in the scripted directory (/dir/.htaccess). Here's my latest attempt:
RewriteEngine On
RewriteRule !index\.php$ item.php
This works redirects everything but /dir/index.php; the problem is it also redirects /dir/ (which resolves to /dir/index.php), and I don't want to specify the index file.
I think the problem might have something to do with the higher level .htaccess (/.htaccess), so I'll post all of that too.
# ERROR DOCUMENTS
ErrorDocument 403 /_structure/403.html
ErrorDocument 404 /_structure/404.html
RewriteEngine on
# ACCESS CONTROLS
RewriteRule ^dir/login_vars\.php$ - [F]
RewriteRule (/|^)php\.ini$ - [F]
RewriteRule (/|^)\.(htaccess|htpasswd|htgroup)$ - [F]
# EXTERNAL REDIRECTS
RewriteCond %{HTTP_HOST} !^(mysite\.com)?$
RewriteRule ^(.*)$ http://mysite.com/$1 [R=301,L]
# INTERNAL REDIRECTS
RewriteRule ^search$ search.php
RewriteRule \.html$ _structure/page.php [NC]
Also, note that there are other files in /dir/, so I can't just redirect if it is not a file.
Any suggestions? Thanks for reading.