Dizzley
Dizzley

Reputation: 487

.htaccess redirect except certain directories or files?

I have a Wordpress site and WP supplies a .htaccess which includes the following:

# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress

That redirects all requests to http://mydomain.com/index.php.

How do I prevent redirects for, e.g., http://mydomain.com/tools or http://mydomain.com/tools/stats.php?

Upvotes: 0

Views: 548

Answers (2)

initall
initall

Reputation: 2385

The [L] is the "last rule" which is similar to "break" in code, see the docs. So add more "last"-line-patterns right after the first index.php line.

(And while I write this: Dan makes a good point that already existing dirs or files are ignored already)

Upvotes: 0

Dan Grossman
Dan Grossman

Reputation: 52372

If tools is a directory, and tools/stats.php is a file, they are already excluded by the two RewriteCond lines.

Upvotes: 1

Related Questions