Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
By firstov on
Hello all,
I understand this topic was discussed a lot, but I'd like to now what you think of this idea.
I need to redirect a lot of old URLs to the new URLs using 301 redirect.
Here is the idea's implementation:
Create redirect.php page and set it to be default error page for 404 error (page not found) using drupal settings.
the content of the page is as following:
if (isset($_SERVER['REQUEST_URI'])) {
$uri = $_SERVER['REQUEST_URI'];
}
switch ($uri)
{
case '/cat/7/34/112/': $url="some_new_content";
break;
case '/cat/65/77/32' : $url="some_other_url";
break;
}
header( "HTTP/1.1 301 Moved Permanently" );
header( "Status: 301 Moved Permanently" );
header( "Location: http://my_new_site/$url" );
exit(0);
In addition I will add header with 404 in the case statement for the default I guess.
Is this something that is going to work or not? What are the risk associated with this implementation?
Comments
I actually found this script
I actually found this script while researching this issue.