Drupal Redirect Paths May Conflict With Existing Directories

Submitted by Matthew on Sun, 12/06/2015 - 21:44

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

Add new comment

Restricted HTML

  • Allowed HTML tags: <a href hreflang> <em> <strong> <cite> <blockquote cite> <code> <ul type> <ol start type> <li> <dl> <dt> <dd> <h2 id> <h3 id> <h4 id> <h5 id> <h6 id>
  • Lines and paragraphs break automatically.
  • Web page addresses and email addresses turn into links automatically.
CAPTCHA
This question is for testing whether or not you are a human visitor and to prevent automated spam submissions.