2

I am trying to forward the location of a directory, e.g., www.example.com/dir to a file in itself, e.g., www.example.com/dir/file.php. The following is my .htaccess configuration:

Redirect /dir http://example.com/dir/file.php. 

I am getting a redirect loop in this fashion:

example.com/dir/file.php/file.php/file.php/+...+file.php ad nauseam.

Fairly new at this logic so clearly I may have missed something.

MrWhite
  • 43,179
  • 8
  • 60
  • 84
user3376899
  • 143
  • 3

1 Answers1

0

The Redirect directive is prefix matching, and everything after the match (ie. /file.php) is appended onto the end of the target URL, hence the redirect loop.

However, you can use RedirectMatch instead, which matches a specific regex, rather than simple prefix matching. For example:

RedirectMatch ^/dir$ /dir/file.php
MrWhite
  • 43,179
  • 8
  • 60
  • 84