开发者

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

开发者 https://www.devze.com 2023-02-06 09:19 出处:网络
I wrote the following mod_rewrite: Options +FollowSymLinks RewriteEngine On RewriteBase / RewriteCond %{SCRIPT_FILENAME} !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://g开发者_开发问答oogle.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?


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

RewriteCond %{REQUEST_URI} !^$
0

精彩评论

暂无评论...
验证码 换一张
取 消