Reputation: 2052
I'd like to set a redirect (preferably with RewriteCond) so that if the requested file is index.php regardless of directory, it will be redirected to another site.
So visiting /index.php or/files/index.php or /stuff/index.php (etc.) will all redirect you to another domain.
Upvotes: 1
Views: 4133
Reputation: 272406
These rules should do it (when placed inside /.htaccess
file):
RewriteEngine On
RewriteRule (?:^|/)index\.php$ http://otherdomain.com/ [R=301,L]
Upvotes: 2
Reputation: 11809
Here is a general way to do it. This rule set should be placed in the .htaccess file in the root directory:
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_URI} index\.php/? [NC]
RewriteRule .* http://otherdomain.com/ [R=301,L]
Redirects permanently any URL that holds index.php
in any position, like
http://mydomain.com/index.php
or
http://mydomain.com/any/folder/quantity/index.php
or
http://mydomain.com/any/folder/quantity/index.php/any/folder/quantity/
To
http://otherdomain.com/
That's it. You don't explain much so nothing is passed to the other domain, just as you say in your question:
Upvotes: 7