Forum Moderators: phranque
Structure was /messageboard/(forum number)/(topic number)
Strucure is messageboard/(forum NAME)/(topic NAME)
http://www.example.com/messageboard/16/16417.html
http://www.example.com/messageboard/mlb/astros-have-no-chance-in-winning-the-central-16417.html
redirect 301 /messageboard/(forum number)http://www.example.com/messageboard/(forum NAME)
#
# Uncomment the statement below if you want to make use of
# HTTP authentication and it does not already work.
# This could be required if you are for example using PHP via Apache CGI.
#
#<IfModule mod_rewrite.c>
#RewriteEngine on
#RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization},L]
#</IfModule>
<Files "config.php">
Order Allow,Deny
Deny from All
</Files>
<Files "common.php">
Order Allow,Deny
Deny from All
</Files>
I think I just need to redirect the subdirectory or forum name
RedirectMatch 301 ^/messageboard/number/(.+)$ http://www.example.com/messageboard/name/$1
I removed the # sign in front of engine on. Is anything else needed?
/messageboard/16/16417.html then the internal rewrite part is very simple. RewriteRule ^messageboard/([0-9]+)/([0-9]+)\.html /my-special-script.php?a=$1&b=$2 [L] RewriteRule ^messageboard/([0-9]+)/([0-9]+).html$ redirect.php?fid=$1&tid=$2 <?php
// database connection setup
$dbhost = "xx";
$dbuser = "#*$!";
$dbpass = "#*$!";
$dbname = "xx";
mysql_connect($dbhost, $dbuser, $dbpass) or die('Error: ' . mysql_error());
mysql_select_db($dbname) or die(mysql_error());
// retrieves the topic id and forum id sent from the htaccess script
$topic_id = $_GET['tid'];
$forum_id = $_GET['fid'];
// sql query to get the topic title
$sql = 'SELECT topic_title AS topic_title
FROM phpbb_topics
WHERE topic_id = '.$topic_id.'';
$result = mysql_query($sql);
$data = mysql_fetch_assoc($result);
$title = $data['topic_title'];
// sql query to get the forum name
$sql = 'SELECT forum_name AS forum_name
FROM phpbb_forums
WHERE forum_id = '.$forum_id.'';
$result = mysql_query($sql);
$data = mysql_fetch_assoc($result);
$name = $data['forum_name'];
// formatting to strip the string from weird characters and add hyphens
$name = strtolower($name);
$name = str_replace(" ", "-", $name);
$name = ereg_replace("[^A-Za-z0-9-]", "", $name );
$title = strtolower($title);
$title = str_replace(" ", "-", $title);
$title = ereg_replace("[^A-Za-z0-9-]", "", $title );
// php redirect to new file name
header( 'Location:/messageboard/'.$name.'/'.$title.'-'.$topic_id.'.html');
?>
// php redirect to new file name
header( 'Location:/messageboard/'.$name.'/'.$title.'-'.$topic_id.'.html');
// php redirect to new file name
header( 'Location:http:www.example.com/messageboard/'.$name.'/'.$title.'-'.$topic_id.'.html');