-1

I migrated a site from a custom built php site (with file types in the urls) to a Drupal site recently. I want to preserve the old url (because they are indexed on search engines) and redirect to the respective new Drupal paths. I have placed this at the top of the .htaccess file: Redirect 301 /path/oldfile.php /node/22

However, the redirect is not taking and the site shows a 404 at http://example.com/path/oldfile.php. If I place this in my .htaccess: Redirect 301 / http://example.org/ then the site is redirected when I go to http://example.com/ so I know that the Apache mods are working.

Any thoughts?

0

Have you tried altering the form of the redirect? That might be invalid -- the target of a redirect should be a full URL.

Try

Redirect 301 /path/oldfile.php http://www.newdomain.com/node/22
0

I solved this by adding the directory /path to my site root. For some reason even though there is no equivalent directory on the new site that corresponds to the url path of the old urls, I still needed an empty directory with the same name, otherwise it was responding with a 404.

  • While it's great that you found a function solution it sounds like you still have an Apache configuration error of some kind. I suggest you check to make sure the .htaccess file is being used, and trying setting the redirect base that's commented out in the default file (and your redirects should be after that directive). – acrosman Jun 7 '16 at 13:30
0

I suggest that you add you rewrite directives right after this (around line 57):

RewriteEngine on

So don't put it right in top/beginning of your .htaccess.

And secondly, I recommend that you try following directives:

RewriteCond ${REQUEST_URI} /path/oldfile.php
RewriteRule (.*) /node/22 [R=301,L] //or index.php?q=node/22

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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