1

I want the .htaccess send each file/directory to my index.php. I have this so far:

RewriteEngine On RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME} -f RewriteCond %{REQUEST_FILENAME} -d RewriteRule ^(.*)$ index.php?urlparam=$1 [NC,L] 


But this error apears on mysite.com/foobar, if directory exists:

Forbidden

You do not have permission to access this document.

If not:

Not Found

The requested document was not found on this server. (404)

1
  • It is unclear (to me) if you would like urls for files or directories, even if they exist, to be routed through index.php Commented Oct 21, 2015 at 20:21

1 Answer 1

1

Having both the !-f and -f set of conditions makes no sense. This is essentially saying:

Perform this rewrite rule if the request does not match an existing file and the request also matches an existing file.

Obviously, you can't have both.

What you want is simply:

RewriteEngine On RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^(.*)$ index.php?urlparam=$1 [NC,L] 
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.