<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
	<channel>
		<title><![CDATA[PunBB Forums — SEF URL redirect?]]></title>
		<link>https://punbb.informer.com/forums/topic/21681/sef-url-redirect/</link>
		<atom:link href="https://punbb.informer.com/forums/feed/rss/topic/21681/" rel="self" type="application/rss+xml" />
		<description><![CDATA[The most recent posts in SEF URL redirect?.]]></description>
		<lastBuildDate>Tue, 03 May 2011 18:08:20 +0000</lastBuildDate>
		<generator>PunBB</generator>
		<item>
			<title><![CDATA[Re: SEF URL redirect?]]></title>
			<link>https://punbb.informer.com/forums/post/140034/#p140034</link>
			<description><![CDATA[<p>Thank you all for this discussion ! </p><p>I have another idea/question : do you think it would be possible to make an URL rewriting at the level of POSTS (not only on topic and forum) with th ID of the post replaced by a small POST URL that would replace the current &quot;<a href="http://punbb.informer.com/forums/post/132999/#p132999">http://punbb.informer.com/forums/post/132999/#p132999</a>&quot; URL of posts --&gt; This URL would be 7 first word of the post for instance (or another rule if there could be some better SEO solution - such as enabling people to give a title to their posts). </p><p>What you think about that ? Is it technically possible ? </p><p>Thank you !</p><p>I think that would create title to posts, and have a blattant SEO effect !</p>]]></description>
			<author><![CDATA[null@example.com (Eretz)]]></author>
			<pubDate>Tue, 03 May 2011 18:08:20 +0000</pubDate>
			<guid>https://punbb.informer.com/forums/post/140034/#p140034</guid>
		</item>
		<item>
			<title><![CDATA[Re: SEF URL redirect?]]></title>
			<link>https://punbb.informer.com/forums/post/132999/#p132999</link>
			<description><![CDATA[<p>I found a better solution. All you need is an extension with the following hooks:</p><p>1) Hook <strong>vf_modify_forum_info</strong></p><div class="codebox"><pre><code>$seo_url = forum_sublink($forum_url[&#039;forum&#039;], $forum_url[&#039;page&#039;], (isset($_GET[&#039;p&#039;]) ? $_GET[&#039;p&#039;] : 1), array($id, sef_friendly($cur_forum[&#039;forum_name&#039;])));
if ($seo_url !== get_current_url())
    header(&#039;Location:&#039;.$seo_url, true, 301);</code></pre></div><p>2) Hook <strong>vt_modify_topic_info</strong></p><div class="codebox"><pre><code>$seo_url = forum_sublink($forum_url[&#039;topic&#039;], $forum_url[&#039;page&#039;], (isset($_GET[&#039;p&#039;]) ? $_GET[&#039;p&#039;] : 1), array($id, sef_friendly($cur_topic[&#039;subject&#039;])));
if ($seo_url !== get_current_url() &amp;&amp; !$pid)
    header(&#039;Location:&#039;.$seo_url, true, 301);</code></pre></div><p>This method is better because:</p><p>1) You don&#039;t have to hack into punbb code.</p><p>2) It prevend duplicate content better, for ex. the following urls (in my website):<br /><a href="http://diendan.sile.vn/viewforum.php?id=36">http://diendan.sile.vn/viewforum.php?id=36</a><br /><a href="http://diendan.sile.vn/forum/36">http://diendan.sile.vn/forum/36</a><br /><a href="http://diendan.sile.vn/forum/36/abc">http://diendan.sile.vn/forum/36/abc</a><br /><a href="http://diendan.sile.vn/forum36-some-stupid-keywords.html">http://diendan.sile.vn/forum36-some-stu … words.html</a><br />....<br />all redirect to <a href="http://diendan.sile.vn/forum36-thu-thuat-tin-hoc-internet-thuong-mai-dien-tu.html">http://diendan.sile.vn/forum36-thu-thua … en-tu.html</a></p><p>Note that if you use fancy url scheme, you can cause duplicate contents when you rename your forum name or post title (for ex, <a href="http://diendan.sile.vn/forum36-some-stupid-keywords.html">http://diendan.sile.vn/forum36-some-stu … words.html</a> and <a href="http://diendan.sile.vn/forum36-thu-thuat-tin-hoc-internet-thuong-mai-dien-tu.html">http://diendan.sile.vn/forum36-thu-thua … en-tu.html</a> above). Using above hooks, only newest url is allowed, others will redirect to this url.</p><p>Hope it can help <img src="https://punbb.informer.com/forums/img/smilies/smile.png" width="15" height="15" alt="smile" /></p>]]></description>
			<author><![CDATA[null@example.com (khonggiannet)]]></author>
			<pubDate>Sun, 27 Dec 2009 01:58:53 +0000</pubDate>
			<guid>https://punbb.informer.com/forums/post/132999/#p132999</guid>
		</item>
		<item>
			<title><![CDATA[Re: SEF URL redirect?]]></title>
			<link>https://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[null@example.com (achtungbaby)]]></author>
			<pubDate>Mon, 13 Jul 2009 14:53:20 +0000</pubDate>
			<guid>https://punbb.informer.com/forums/post/129013/#p129013</guid>
		</item>
		<item>
			<title><![CDATA[Re: SEF URL redirect?]]></title>
			<link>https://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[null@example.com (Slavok)]]></author>
			<pubDate>Fri, 10 Jul 2009 07:16:17 +0000</pubDate>
			<guid>https://punbb.informer.com/forums/post/128948/#p128948</guid>
		</item>
		<item>
			<title><![CDATA[Re: SEF URL redirect?]]></title>
			<link>https://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[null@example.com (achtungbaby)]]></author>
			<pubDate>Thu, 09 Jul 2009 15:53:53 +0000</pubDate>
			<guid>https://punbb.informer.com/forums/post/128933/#p128933</guid>
		</item>
		<item>
			<title><![CDATA[Re: SEF URL redirect?]]></title>
			<link>https://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[null@example.com (Slavok)]]></author>
			<pubDate>Thu, 09 Jul 2009 09:26:37 +0000</pubDate>
			<guid>https://punbb.informer.com/forums/post/128924/#p128924</guid>
		</item>
		<item>
			<title><![CDATA[Re: SEF URL redirect?]]></title>
			<link>https://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[null@example.com (achtungbaby)]]></author>
			<pubDate>Sun, 05 Jul 2009 09:24:53 +0000</pubDate>
			<guid>https://punbb.informer.com/forums/post/128839/#p128839</guid>
		</item>
		<item>
			<title><![CDATA[Re: SEF URL redirect?]]></title>
			<link>https://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[null@example.com (achtungbaby)]]></author>
			<pubDate>Fri, 03 Jul 2009 11:17:36 +0000</pubDate>
			<guid>https://punbb.informer.com/forums/post/128800/#p128800</guid>
		</item>
		<item>
			<title><![CDATA[Re: SEF URL redirect?]]></title>
			<link>https://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[null@example.com (Grant)]]></author>
			<pubDate>Mon, 25 May 2009 14:06:23 +0000</pubDate>
			<guid>https://punbb.informer.com/forums/post/127948/#p127948</guid>
		</item>
		<item>
			<title><![CDATA[Re: SEF URL redirect?]]></title>
			<link>https://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[null@example.com (Slavok)]]></author>
			<pubDate>Mon, 25 May 2009 10:12:11 +0000</pubDate>
			<guid>https://punbb.informer.com/forums/post/127940/#p127940</guid>
		</item>
		<item>
			<title><![CDATA[SEF URL redirect?]]></title>
			<link>https://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="https://punbb.informer.com/forums/img/smilies/smile.png" width="15" height="15" alt="smile" /></p>]]></description>
			<author><![CDATA[null@example.com (Grant)]]></author>
			<pubDate>Sun, 24 May 2009 08:01:18 +0000</pubDate>
			<guid>https://punbb.informer.com/forums/post/127916/#p127916</guid>
		</item>
	</channel>
</rss>
