Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

There is a way to redirect some files named for example file.php and placed into randoms spots of the webspace (web-root, inside one or more dir, etc) to mysite.com/test ?

Example 1:

I want to redirect file.php placed in root to mysite.com/test

Example 2:

I want to redirect file.php placed inside a random dir to mysite.com/test

share|improve this question
Did you try using mod_rewrite? The second case is not clear. Do you want to redirect all files named file.php in any location? –  Khaled Jan 5 '13 at 10:53
yes i want to redirect all files named file.php in any location –  Alex Jan 5 '13 at 10:55

1 Answer 1

You can use the following config to redirect any URL which ends with file.php:

RewriteEngine on
RewriteCond %{REQUEST_URI} /file.php$
RewriteRule file.php$ http://mysite.com/test [R,L]
share|improve this answer
To explain you further, please visit this link httpd.apache.org/docs/current/mod/mod_rewrite.html. –  user1149244 Jan 5 '13 at 14:29

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.