Simple Machines Community Forum

SMF Support => Server Performance and Configuration => Topic started by: Rumbaar on September 04, 2008, 07:32:35 AM

Title: Server redirects via .htaccess
Post by: Rumbaar on September 04, 2008, 07:32:35 AM
I've since moved my main site from php-nuke to SMF and looking to better redirect old URL's if possible, and I'm having trouble working out rewriteCond and rewriteRule to perform what I want to do.

For the first two URL's want to take the ID numbers and pass them to the target URL.

So I want to redirect this URL:
modules.php?name=Forums&file=viewtopic&t=6825
To:
index.php?topic=6825

Also from:
modules.php?name=Forums&file=profile&mode=viewprofile&u=232
To:
index.php?action=profile;u=232

Then want to capture any left over URL's that start with
modules.php
and redirect to base
index.php of my main URL.

Any times and assistance would be appreciated.
Title: Re: Server redirects via .htaccess
Post by: ThorstenE on September 06, 2008, 03:09:20 PM
not an .htaccess solution, but a solution ;)

Code (modules.php) Select

<?php
//check ID_TOPIC
if (isset($_REQUEST['t']))
{
$newurl 'Location: index.php?topic='.$_REQUEST['t'];
header('HTTP/1.1 301 Moved Permanently');
header($newurl);
header('Connection: close');
}

//check ID_MEMBER
elseif (isset($_REQUEST['u']))
{
$newurl 'Location: index.php?action=profile;u='.$_REQUEST['u'];
header('HTTP/1.1 301 Moved Permanently');
header($newurl);
header('Connection: close');
}

//Redirecht to index.php
else 
{
$newurl 'Location: index.php';
header('HTTP/1.1 301 Moved Permanently');
header($newurl);
header('Connection: close');
}
?>

Title: Re: Server redirects via .htaccess
Post by: Rumbaar on September 06, 2008, 09:22:19 PM
Sweet thx TE, any solution that works ... will work for me.  I'll test it out and see how it goes.

EDIT: Tested, and it works PERFECTLY! and I'll be able to add to that as well if needed.

Thank you!
Title: Re: Server redirects via .htaccess
Post by: radu81 on October 16, 2013, 05:48:06 AM
great solution, thank you!