[htaccess redirect] old phpbb url > new smf url

Started by Nigh7mar3, May 13, 2007, 11:36:33 AM

Previous topic - Next topic

Nigh7mar3

How many of us convert their board from phpbb to smf and lose all the hard work on google?  >:(

I wrote a little piece of solution. ;)

Its not complete but it works for the more important urls

It redirect these pages to new urls

  • forums
  • topics
  • members profile
  • profile page
  • search
  • members list
  • faq
  • pm
  • online members

RewriteEngine On
RewriteCond %{QUERY_STRING} ^f=([0-9]+).*$
RewriteRule ^viewforum.php$ /forums/index.php?board=%1.0 [R=301,L]
#
RewriteCond %{QUERY_STRING} ^t=([0-9]+).*$
RewriteRule ^viewtopic.php$ /forums/index.php?topic=%1.0 [R=301,L]
#
RewriteCond %{QUERY_STRING} ^mode=viewprofile&u=([0-9]+)$
RewriteRule ^profile.php$ /forums/index.php?action=profile;u=%1 [R=301,L,NE]
#
RewriteRule ^search.php$ /forums/index.php?action=search [R=301,L]
RewriteRule ^profile.php$ /forums/index.php?action=profile [R=301,L]
RewriteRule ^faq.php$ /forums/index.php?action=help [R=301,L]
RewriteRule ^privmsg.php$ /forums/index.php?action=pm [R=301,L]
RewriteRule ^memberlist.php$ /forums/index.php?action=mlist [R=301,L]
RewriteRule ^viewonline.php$ /forums/index.php?action=who [R=301,L]


Mine phpbb installation is in hxxp:foo.com/forum [nonactive] and I redirect to hxxp:foo.com/forums [nonactive], the smf dir

So, you need only to create .htaccess file in your old phpbb directory, and copy this code in it. Rember to change the word forums to your SMF location.

Live example
Forum Index Url:
hxxp:userbarmaker.com/forum/ [nonactive]

Forum Url:
hxxp:userbarmaker.com/forum/viewforum.php?f=3 [nonactive]

Topic Url:
hxxp:userbarmaker.com/forum/vietopic.php?t=797 [nonactive]

Cya

madalin

Got pretty urls and still want to fix things ?

Add this to your .htaccess file (in your forum directory)

For example, my old forum (phpBB) was located in a subdirectory /forum (hxxp:www.tg-jiu.ro/forum/ [nonactive]) and my new one is located in the same directory.

So if your OLD forum is /forum and your NEW one is /forums change the /forum/index.php.... to /forums/index....
RewriteCond %{QUERY_STRING} ^f=([0-9]+).*$
RewriteRule ^viewforum.php$ /forum/index.php?pretty;board=%1.0 [R=301,L]
#
RewriteCond %{QUERY_STRING} ^t=([0-9]+).*$
RewriteRule ^viewtopic.php$ /forum/index.php?topic=%1.0 [R=301,L]
#
RewriteCond %{QUERY_STRING} ^mode=viewprofile&u=([0-9]+)$
RewriteRule ^profile.php$ /forum/index.php?action=profile;u=%1 [R=301,L,NE]
#
RewriteRule ^search.php$ /forum/index.php?action=search [R=301,L]
RewriteRule ^profile.php$ /forum/index.php?action=profile [R=301,L]
RewriteRule ^faq.php$ /forum/index.php?action=help [R=301,L]
RewriteRule ^privmsg.php$ /forum/index.php?action=pm [R=301,L]
RewriteRule ^memberlist.php$ /forum/index.php?action=mlist [R=301,L]
RewriteRule ^viewonline.php$ /forum/index.php?action=who [R=301,L]


L.E: P.S: you can see a working demo by going to
hxxp:www.tg-jiu.ro/forum/viewtopic.php?t=67 [nonactive]
or
hxxp:www.tg-jiu.ro/forum/viewforum.php?f=11 [nonactive]

:)
With great power, comes great responsability.
hxxp:www.tg-jiu.ro [nonactive], and hxxp:www.tg-jiu.ro/forum/ [nonactive]

Nigh7mar3

n1 madalin but you need to fix your forum cause there is the PHPSESID in your urls, its not good.

madalin

The phpsessid always gets appended to the URL the firs time you load a forum. I think :)
With great power, comes great responsability.
hxxp:www.tg-jiu.ro [nonactive], and hxxp:www.tg-jiu.ro/forum/ [nonactive]

armybase.us

Quote from: madalin on May 31, 2007, 11:03:14 AM
Got pretty urls and still want to fix things ?

Add this to your .htaccess file (in your forum directory)

For example, my old forum (phpBB) was located in a subdirectory /forum (hxxp:www.tg-jiu.ro/forum/ [nonactive]) and my new one is located in the same directory.

So if your OLD forum is /forum and your NEW one is /forums change the /forum/index.php.... to /forums/index....
RewriteCond %{QUERY_STRING} ^f=([0-9]+).*$
RewriteRule ^viewforum.php$ /forum/index.php?pretty;board=%1.0 [R=301,L]
#
RewriteCond %{QUERY_STRING} ^t=([0-9]+).*$
RewriteRule ^viewtopic.php$ /forum/index.php?topic=%1.0 [R=301,L]
#
RewriteCond %{QUERY_STRING} ^mode=viewprofile&u=([0-9]+)$
RewriteRule ^profile.php$ /forum/index.php?action=profile;u=%1 [R=301,L,NE]
#
RewriteRule ^search.php$ /forum/index.php?action=search [R=301,L]
RewriteRule ^profile.php$ /forum/index.php?action=profile [R=301,L]
RewriteRule ^faq.php$ /forum/index.php?action=help [R=301,L]
RewriteRule ^privmsg.php$ /forum/index.php?action=pm [R=301,L]
RewriteRule ^memberlist.php$ /forum/index.php?action=mlist [R=301,L]
RewriteRule ^viewonline.php$ /forum/index.php?action=who [R=301,L]


L.E: P.S: you can see a working demo by going to
hxxp:www.tg-jiu.ro/forum/viewtopic.php?t=67 [nonactive]
or
hxxp:www.tg-jiu.ro/forum/viewforum.php?f=11 [nonactive]

:)

gotcha..gotta try it. I need to redirect 301 those old bad urls to a new pretty one :D

Jesus Friends

#5
Many thanks friends ... that was so beautiful and useful for me to keep all archived pages at google and other search engines ...

since there are some important kinds of urls which include forum No. or posts No.
these kinds also need to be redirected such as:

/phpbb/viewtopic.php?f=11&t=1111 >> /smf/index.php?&topic=1111.0
/phpbb/viewtopic.php?f=11&p=111111 >> smf/index.php?&msg=111111.0

I added a suitable solution ... may it will be helpful  ;)

RewriteEngine On
RewriteCond %{QUERY_STRING} ^f=([0-9]+).*$
RewriteRule ^viewforum.php$ /forum/index.php?board=%1.0 [R=301,L]
#
RewriteCond %{QUERY_STRING} ^t=([0-9]+).*$
RewriteRule ^viewtopic.php$ /forum/index.php?topic=%1.0 [R=301,L]

#
RewriteCond %{QUERY_STRING} ^f=([0-9]+)&t=([0-9]+).*$
RewriteRule ^viewtopic.php$ /forum/index.php?&topic=%2.0 [R=301,L]

#
RewriteCond %{QUERY_STRING} ^f=([0-9]+)&p=([0-9]+).*$
RewriteRule ^viewtopic.php$ /forum/index.php?msg=%2.0 [R=301,L]

#
RewriteCond %{QUERY_STRING} ^p=([0-9]+).*$
RewriteRule ^viewtopic.php$ /forum/index.php?msg=%1.0 [R=301,L]

#
RewriteCond %{QUERY_STRING} ^mode=viewprofile&u=([0-9]+)$
RewriteRule ^profile.php$ /forum/index.php?action=profile;u=%1 [R=301,L,NE]
#
RewriteRule ^search.php$ /forum/index.php?action=search [R=301,L]
RewriteRule ^profile.php$ /forum/index.php?action=profile [R=301,L]
RewriteRule ^faq.php$ /forum/index.php?action=help [R=301,L]
RewriteRule ^privmsg.php$ /forum/index.php?action=pm [R=301,L]
RewriteRule ^memberlist.php$ /forum/index.php?action=mlist [R=301,L]
RewriteRule ^viewonline.php$ /forum/index.php?action=who [R=301,L]


sorry for my english  :-[
My SMF version is 2.0 RC3
the link is: www.Jesus-friends.com/forum
The default language is Arabic

I LOVE SMF!

dougiefresh

Thank God for this topic!  Otherwise, I would've wasted several hours trying to figure this out!  Thanks!

Advertisement: