Rodrigo Vieira
Rodrigo Vieira

Reputation: 311

Rewrite - Redirecting all without index.php

I have a index.php file blank and Loader.php file in my root folder and have the following code:

RewriteEngine On
RewriteBase /
RewriteRule . Loader.php [L]

When i remove the index.php file (it has nothing) Rewrite does not work and the Apache back an "Index of".

How to delete the "index.php" and keep Rewrite working?

Upvotes: 1

Views: 101

Answers (1)

Jon Lin
Jon Lin

Reputation: 143886

Try changing your rule's pattern from . to ^. The . means there must be at least one character in the request. If you try loading / (which is a blank request), the . pattern won't match it. Then, because you have an index file, that gets mapped and the index file gets put through the rules. The second time around . matches because there's characters in the request.

RewriteRule ^ Loader.php [L]

Upvotes: 3

Related Questions