Trufa
Trufa

Reputation: 40747

Mod_rewrite in apache not working with "hidden" /index.php (but working with index.php)

I wrote the following mod_rewrite:

Options +FollowSymLinks
RewriteEngine On
RewriteBase /
RewriteCond %{SCRIPT_FILENAME} !index\.php$
RewriteCond %{SCRIPT_FILENAME} !redirect\.php$
RewriteRule ^(.*)$ http://google.com [L,R]

Which works great except you actually have to go to /index.php

What I mean is that if you go to example.com/index.php it works fine but not in example.com (which actually is index.php - you just don't see it).

Of course it doesn't work for example.com/ either.

Could anyone help me how to establish this exception.

Thanks in advance, please ask anything that is no clear enough!

EDIT:

I'll try to put it simpler:

The code as it is redirects ALL URLs to http://google.com

except index.php and redirect.php

So when the URL is example.com/index.php it doesn't redirect (which is fine)

Wut when the URL is example.com is DOES redirect and I don't want it to.

Clearer?

Upvotes: 1

Views: 586

Answers (1)

noodl
noodl

Reputation: 17418

It's not at all clear what you're trying to achieve but to answer your question directly, add another condition:

RewriteCond %{REQUEST_URI} !^$

Upvotes: 1

Related Questions