News:

Bored?  Looking to kill some time?  Want to chat with other SMF users?  Join us in IRC chat or Discord

Main Menu

Server redirects via .htaccess

Started by Rumbaar, September 04, 2008, 07:32:35 AM

Previous topic - Next topic

Rumbaar

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.
"An important reward for a job well done is a personal sense of worthwhile achievement."

[ Themes ]

ThorstenE

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');
}
?>


Rumbaar

#2
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!
"An important reward for a job well done is a personal sense of worthwhile achievement."

[ Themes ]

radu81

sorry for my bad english

Advertisement: