<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0">
	<channel>
		<title><![CDATA[PunBB Forums - SEF URL redirect?]]></title>
		<link>http://punbb.informer.com/forums/topic/21681/sef-url-redirect/</link>
		<description><![CDATA[The most recent posts in SEF URL redirect?.]]></description>
		<lastBuildDate>Mon, 13 Jul 2009 14:53:20 +0000</lastBuildDate>
		<generator>PunBB</generator>
		<item>
			<title><![CDATA[Re: SEF URL redirect?]]></title>
			<link>http://punbb.informer.com/forums/post/129013/#p129013</link>
			<description><![CDATA[<p>thank you very much, I&#039;ll try to refine it.</p>]]></description>
			<author><![CDATA[dummy@example.com (achtungbaby)]]></author>
			<pubDate>Mon, 13 Jul 2009 14:53:20 +0000</pubDate>
			<guid>http://punbb.informer.com/forums/post/129013/#p129013</guid>
		</item>
		<item>
			<title><![CDATA[Re: SEF URL redirect?]]></title>
			<link>http://punbb.informer.com/forums/post/128948/#p128948</link>
			<description><![CDATA[<p>In this case script will look like:<br /></p><div class="codebox"><pre><code>&lt;?php

define(&#039;FORUM_ROOT&#039;, &#039;./&#039;);
require FORUM_ROOT.&#039;include/common.php&#039;;

$id = isset($_GET[&#039;id&#039;]) ? intval($_GET[&#039;id&#039;]) : 0;
if ($id &lt; 1)
    message($lang_common[&#039;Bad request&#039;]);

// Fetch some info about the topic
if (preg_match(&#039;~.*viewtopic.*~&#039;, $_SERVER[&#039;REQUEST_URI&#039;]))
{
    $query = array(
        &#039;SELECT&#039;    =&gt; &#039;t.subject AS subject&#039;,
        &#039;FROM&#039;        =&gt; &#039;topics AS t&#039;,
        &#039;JOINS&#039;        =&gt; array(
            array(
                &#039;INNER JOIN&#039;    =&gt; &#039;forums AS f&#039;,
                &#039;ON&#039;            =&gt; &#039;f.id=t.forum_id&#039;
            ),
            array(
                &#039;LEFT JOIN&#039;        =&gt; &#039;forum_perms AS fp&#039;,
                &#039;ON&#039;            =&gt; &#039;(fp.forum_id=f.id AND fp.group_id=&#039;.$forum_user[&#039;g_id&#039;].&#039;)&#039;
            )
        ),
        &#039;WHERE&#039;        =&gt; &#039;(fp.read_forum IS NULL OR fp.read_forum=1) AND t.id=&#039;.$id.&#039; AND t.moved_to IS NULL&#039;
    );
    $page = &#039;viewtopic&#039;;
}
else
{
    $query = array(
        &#039;SELECT&#039;    =&gt; &#039;f.forum_name AS subject&#039;,
        &#039;FROM&#039;        =&gt; &#039;forums AS f&#039;,
        &#039;JOINS&#039;        =&gt; array(
            array(
                &#039;LEFT JOIN&#039;        =&gt; &#039;forum_perms AS fp&#039;,
                &#039;ON&#039;            =&gt; &#039;(fp.forum_id=f.id AND fp.group_id=&#039;.$forum_user[&#039;g_id&#039;].&#039;)&#039;
            )
        ),
        &#039;WHERE&#039;        =&gt; &#039;(fp.read_forum IS NULL OR fp.read_forum=1) AND f.id=&#039;.$id
    );
    $page = &#039;viewforum&#039;;
}
$result = $forum_db-&gt;query_build($query) or error(__FILE__, __LINE__);
if (!$forum_db-&gt;num_rows($result))
    message($lang_common[&#039;Bad request&#039;]);

list($subject) = $forum_db-&gt;fetch_row($result);

if ($page == &#039;viewtopic&#039;)
    $redirtect_url = str_replace(&#039;&amp;amp;&#039;, &#039;&amp;&#039;, forum_link($forum_url[&#039;topic&#039;], array($id, sef_friendly($subject))));
else if ($page == &#039;viewforum&#039;)
    $redirtect_url = str_replace(&#039;&amp;amp;&#039;, &#039;&amp;&#039;, forum_link($forum_url[&#039;forum&#039;], array($id, sef_friendly($subject))));

header(&#039;HTTP/1.1 301 Moved Permanently&#039;);    
header(&#039;Location: &#039;.$redirtect_url);

?&gt;</code></pre></div><p>And the file &quot;&lt;FORUM_ROOT&gt;/.htaccess&quot; will be:<br /></p><div class="codebox"><pre><code># BEGIN PunBB

&lt;IfModule mod_rewrite.c&gt;
# MultiViews interfers with proper rewriting
Options -MultiViews

RewriteEngine On

# Uncomment and properly set the RewriteBase if the rewrite rules are not working properly
#RewriteBase /
RewriteCond %{REQUEST_FILENAME} viewtopic.* [OR]
RewriteCond %{REQUEST_FILENAME} viewforum.*
RewriteRule . redirect_viewtopic.php [L]

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . rewrite.php [L]
&lt;/IfModule&gt;

# END PunBB</code></pre></div>]]></description>
			<author><![CDATA[dummy@example.com (Slavok)]]></author>
			<pubDate>Fri, 10 Jul 2009 07:16:17 +0000</pubDate>
			<guid>http://punbb.informer.com/forums/post/128948/#p128948</guid>
		</item>
		<item>
			<title><![CDATA[Re: SEF URL redirect?]]></title>
			<link>http://punbb.informer.com/forums/post/128933/#p128933</link>
			<description><![CDATA[<p>Great !</p><p>But can you help me to make the same for viewforum.php ?</p><p>edit : i do this :</p><div class="codebox"><pre><code>&lt;?php

define(&#039;FORUM_ROOT&#039;, &#039;./&#039;);
require FORUM_ROOT.&#039;include/common.php&#039;;

$id = isset($_GET[&#039;id&#039;]) ? intval($_GET[&#039;id&#039;]) : 0;
if ($id &lt; 1)
    message($lang_common[&#039;Bad request&#039;]);

// Fetch some info about the topic
$query = array(
    &#039;SELECT&#039;    =&gt; &#039;t.forum_name&#039;,
    &#039;FROM&#039;        =&gt; &#039;forums AS t&#039;,
    &#039;JOINS&#039;        =&gt; array(
        array(
            &#039;INNER JOIN&#039;    =&gt; &#039;forums AS f&#039;,
            &#039;ON&#039;            =&gt; &#039;f.id=t.id&#039;
        ),
        array(
            &#039;LEFT JOIN&#039;        =&gt; &#039;forum_perms AS fp&#039;,
            &#039;ON&#039;            =&gt; &#039;(fp.forum_id=f.id AND fp.group_id=&#039;.$forum_user[&#039;g_id&#039;].&#039;)&#039;
        )
    ),
    &#039;WHERE&#039;        =&gt; &#039;(fp.read_forum IS NULL OR fp.read_forum=1) AND t.id=&#039;.$id.&#039;&#039;
);
$result = $forum_db-&gt;query_build($query) or error(__FILE__, __LINE__);
if (!$forum_db-&gt;num_rows($result))
    message($lang_common[&#039;Bad request&#039;]);

list($topic_subject) = $forum_db-&gt;fetch_row($result);
header(&quot;HTTP/1.1 301 Moved Permanently&quot;);
header(&#039;Location: &#039;.str_replace(&#039;&amp;amp;&#039;, &#039;&amp;&#039;, forum_link($forum_url[&#039;forum&#039;], array($id, sef_friendly($topic_subject)))));

?&gt; </code></pre></div><p>is it good ?</p><p>ps : I just added that as well on the first script</p><div class="codebox"><pre><code>header(&quot;HTTP/1.1 301 Moved Permanently&quot;);</code></pre></div>]]></description>
			<author><![CDATA[dummy@example.com (achtungbaby)]]></author>
			<pubDate>Thu, 09 Jul 2009 15:53:53 +0000</pubDate>
			<guid>http://punbb.informer.com/forums/post/128933/#p128933</guid>
		</item>
		<item>
			<title><![CDATA[Re: SEF URL redirect?]]></title>
			<link>http://punbb.informer.com/forums/post/128924/#p128924</link>
			<description><![CDATA[<p>I&#039;ve created an example of how to redirect all request from viewtopic.php according to SEF-url.<br /></p><ul><li><p>Edit &quot;&lt;FORUM_ROOT&gt;/.htaccess&quot;. It should be:</p></li></ul><div class="codebox"><pre><code># BEGIN PunBB

&lt;IfModule mod_rewrite.c&gt;
# MultiViews interfers with proper rewriting
Options -MultiViews

RewriteEngine On

# Uncomment and properly set the RewriteBase if the rewrite rules are not working properly
#RewriteBase /
RewriteCond %{REQUEST_FILENAME} viewtopic.*
RewriteRule . redirect_viewtopic.php [L]

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . rewrite.php [L]
&lt;/IfModule&gt;

# END PunBB</code></pre></div><ul><li><p>Create the file &quot;&lt;FORUM_ROOT&gt;/redirect_viewtopic.php&quot; with this code:</p></li></ul><div class="codebox"><pre><code>&lt;?php

define(&#039;FORUM_ROOT&#039;, &#039;./&#039;);
require FORUM_ROOT.&#039;include/common.php&#039;;

$id = isset($_GET[&#039;id&#039;]) ? intval($_GET[&#039;id&#039;]) : 0;
if ($id &lt; 1)
    message($lang_common[&#039;Bad request&#039;]);

// Fetch some info about the topic
$query = array(
    &#039;SELECT&#039;    =&gt; &#039;t.subject&#039;,
    &#039;FROM&#039;        =&gt; &#039;topics AS t&#039;,
    &#039;JOINS&#039;        =&gt; array(
        array(
            &#039;INNER JOIN&#039;    =&gt; &#039;forums AS f&#039;,
            &#039;ON&#039;            =&gt; &#039;f.id=t.forum_id&#039;
        ),
        array(
            &#039;LEFT JOIN&#039;        =&gt; &#039;forum_perms AS fp&#039;,
            &#039;ON&#039;            =&gt; &#039;(fp.forum_id=f.id AND fp.group_id=&#039;.$forum_user[&#039;g_id&#039;].&#039;)&#039;
        )
    ),
    &#039;WHERE&#039;        =&gt; &#039;(fp.read_forum IS NULL OR fp.read_forum=1) AND t.id=&#039;.$id.&#039; AND t.moved_to IS NULL&#039;
);
$result = $forum_db-&gt;query_build($query) or error(__FILE__, __LINE__);
if (!$forum_db-&gt;num_rows($result))
    message($lang_common[&#039;Bad request&#039;]);

list($topic_subject) = $forum_db-&gt;fetch_row($result);
header(&#039;Location: &#039;.str_replace(&#039;&amp;amp;&#039;, &#039;&amp;&#039;, forum_link($forum_url[&#039;topic&#039;], array($id, sef_friendly($topic_subject)))));

?&gt;</code></pre></div><p>To create redirection for other forum links, you need to add corresponding RewriteCond to the &quot;&lt;FORUM_ROOT&gt;/.htaccess&quot; and add generation of the corresponding link to the file.</p>]]></description>
			<author><![CDATA[dummy@example.com (Slavok)]]></author>
			<pubDate>Thu, 09 Jul 2009 09:26:37 +0000</pubDate>
			<guid>http://punbb.informer.com/forums/post/128924/#p128924</guid>
		</item>
		<item>
			<title><![CDATA[Re: SEF URL redirect?]]></title>
			<link>http://punbb.informer.com/forums/post/128839/#p128839</link>
			<description><![CDATA[<p>Nobody kown ?</p><p>It&#039;s very important for me. This board &nbsp; &nbsp; has 52000 posts and 4 years old. It has many external links.</p>]]></description>
			<author><![CDATA[dummy@example.com (achtungbaby)]]></author>
			<pubDate>Sun, 05 Jul 2009 09:24:53 +0000</pubDate>
			<guid>http://punbb.informer.com/forums/post/128839/#p128839</guid>
		</item>
		<item>
			<title><![CDATA[Re: SEF URL redirect?]]></title>
			<link>http://punbb.informer.com/forums/post/128800/#p128800</link>
			<description><![CDATA[<p>Hello, I agree with Grant. I also have an old version 1.2.xxx PunBB forum and I would like to switch to PunBB 1.3.4 with rewriteable urls.</p><p>Outside I see the two urls, old and new, are present.</p><p>I would like to permanently redirect the old urls to the new. I do not know how.</p><p>Does anyone has a solution to offer?</p><p>I want to avoid duplicate content.</p>]]></description>
			<author><![CDATA[dummy@example.com (achtungbaby)]]></author>
			<pubDate>Fri, 03 Jul 2009 11:17:36 +0000</pubDate>
			<guid>http://punbb.informer.com/forums/post/128800/#p128800</guid>
		</item>
		<item>
			<title><![CDATA[Re: SEF URL redirect?]]></title>
			<link>http://punbb.informer.com/forums/post/127948/#p127948</link>
			<description><![CDATA[<p>I don&#039;t think there is a problem per se. It&#039;s just that I have had difficulties getting search engines to accept duplicate content before when I changed URLs and the solution seems to be a redirect.</p>]]></description>
			<author><![CDATA[dummy@example.com (Grant)]]></author>
			<pubDate>Mon, 25 May 2009 14:06:23 +0000</pubDate>
			<guid>http://punbb.informer.com/forums/post/127948/#p127948</guid>
		</item>
		<item>
			<title><![CDATA[Re: SEF URL redirect?]]></title>
			<link>http://punbb.informer.com/forums/post/127940/#p127940</link>
			<description><![CDATA[<p>Why do you think there is problem with new links? Maybe search engines don&#039;t crawl you forum again with new SEF links?</p>]]></description>
			<author><![CDATA[dummy@example.com (Slavok)]]></author>
			<pubDate>Mon, 25 May 2009 10:12:11 +0000</pubDate>
			<guid>http://punbb.informer.com/forums/post/127940/#p127940</guid>
		</item>
		<item>
			<title><![CDATA[SEF URL redirect?]]></title>
			<link>http://punbb.informer.com/forums/post/127916/#p127916</link>
			<description><![CDATA[<p>I recently enabled SEF URLs on all my PunBB forums but am having difficuly getting the search engines to index the new links. I have re-submitted sitemaps etc.</p><p>I think that the root of the problem lies in duplicate content. Is there some way to get:</p><p><a href="http://punbb.informer.com/forums/viewtopic.php?id=21681">viewtopic.php?id=21681</a></p><p>to redirect to:</p><p><a href="http://punbb.informer.com/forums/topic/21681/sef-url-redirect/">topic/21681/sef-url-redirect/</a></p><p>instead of just displaying the same content?</p><p>Thanks <img src="http://punbb.informer.com/forums/img/smilies/smile.png" width="15" height="15" alt="smile" /></p>]]></description>
			<author><![CDATA[dummy@example.com (Grant)]]></author>
			<pubDate>Sun, 24 May 2009 08:01:18 +0000</pubDate>
			<guid>http://punbb.informer.com/forums/post/127916/#p127916</guid>
		</item>
	</channel>
</rss>
