Drupal Redirect Paths May Conflict With Existing Directories

If you are familiar with the Drupal Redirect module, you know it can be a convenient way of creating redirects from URLs that don't really exist.  For example, you can create a redirect for yoursite.com/music to redirect to another website dedicated to your favorite music. 

But what if the URL you want to use as a redirect does already exist?  What if you want yoursite.com/testfolder to redirect to drupal.org?  It won't work--you will get an error message.   If you have already created a folder called testfolder, as in the image below, then your redirect won't work. 

testfolder already exists as a subdirectory

In the example below, the yoursite.com/music redirect will work, but yoursite.com/testfolder will not.  Generally, if you are a Drupal developer, you are not typically creating new directories at the root of your site, so you probably won't have an issue like this.  But it did happen on one of our sites recently, and it wasn't until I saw that we already had a folder with the same name as the redirect that I was able to easily fix the the problem by just putting an index.php file in the folder with a redirect using the header() function.

Example of Redirect module

 

Tags