Need some help with 301 redirect

Discussions and support about the different URL Rewriting techniques for phpBB.

Moderator: Moderators

Need some help with 301 redirect

Postby Dangerell » Fri Nov 27, 2009 11:53 am

Hello,

I recently change some of my site links and i want to redirect the old ones to the new urls. I use phpbb-seo mod with advance url type and used this code for redirect in .htaccess

Code: Select all
Redirect 301 /actiune.html http://www.topfilmeonline.com/filme-online-actiune.html
Redirect 301 /animatie.html http://www.topfilmeonline.com/filme-online-animatie.html
Redirect 301 /aventuri.html http://www.topfilmeonline.com/filme-online-aventuri.html
Redirect 301 /biografice.html http://www.topfilmeonline.com/filme-online-biografice.html
Redirect 301 /comedie.html http://www.topfilmeonline.com/filme-online-comedie.html
Redirect 301 /crima.html http://www.topfilmeonline.com/filme-online-crima.html
Redirect 301 /documentare.html http://www.topfilmeonline.com/filme-online-documentare.html
Redirect 301 /drama.html http://www.topfilmeonline.com/filme-online-drama.html
Redirect 301 /familie.html http://www.topfilmeonline.com/filme-online-familie.html
Redirect 301 /fantastic.html http://www.topfilmeonline.com/filme-online-fantastic.html
Redirect 301 /horror.html http://www.topfilmeonline.com/filme-online-horror.html
Redirect 301 /indiene.html http://www.topfilmeonline.com/filme-online-indiene.html
Redirect 301 /istorice.html http://www.topfilmeonline.com/filme-online-istorice.html
Redirect 301 /mister.html http://www.topfilmeonline.com/filme-online-mister.html
Redirect 301 /muzical.html http://www.topfilmeonline.com/filme-online-muzical.html
Redirect 301 /razboi.html http://www.topfilmeonline.com/filme-online-razboi.html
Redirect 301 /romanesti.html http://www.topfilmeonline.com/filme-online-romanesti.html
Redirect 301 /romantice.html http://www.topfilmeonline.com/filme-online-romantice.html
Redirect 301 /sf.html http://www.topfilmeonline.com/filme-online-sf.html
Redirect 301 /sport.html http://www.topfilmeonline.com/filme-online-sport.html
Redirect 301 /thriller.html http://www.topfilmeonline.com/filme-online-thriller.html
Redirect 301 /tv.html http://www.topfilmeonline.com/filme-online-tv.html
Redirect 301 /xxx.html http://www.topfilmeonline.com/filme-online-xxx.html
Redirect 301 /the-simpsons.html http://www.topfilmeonline.com/the-simpsons-online.html
Redirect 301 /heroes.html http://www.topfilmeonline.com/heroes-online.html
Redirect 301 /filme-online.html http://www.topfilmeonline.com/filme-online-gratis.html


But the problem is that when i access this link for example :
Code: Select all
http://www.topfilmeonline.com/actiune.html

it redirects me to this:
Code: Select all
http://www.topfilmeonline.com/filme-online-actiune.html?forum_uri=actiune

instead of this:
Code: Select all
http://www.topfilmeonline.com/filme-online-actiune.html


Can someone please tell me what seems to be the problem and how to fix it?

Thank you in advance.
User avatar
Dangerell
 
Posts: 10
Joined: Thu Jul 23, 2009 8:57 am

Advertisement

Re: Need some help with 301 redirect

Postby dcz » Fri Nov 27, 2009 12:47 pm

Try
Code: Select all
RewriteRule ^(actiune|animatie|aventuri|biografice|comedie|crima|documentare|drama|familie|fantastic|horror|indiene|istorice|mister|muzical|razboi|romanesti|romantice|sf|sport|thriller|tv|xxx)\.html$ http://www.topfilmeonline.com/filme-online-$1.html [QSA,L,NC,R=301]
RewriteRule ^(the-simpsons|heroes)\.html$ http://www.topfilmeonline.com/$1-online.html [QSA,L,NC,R=301]
RewriteRule ^filme-online\.html$ http://www.topfilmeonline.com/filme-online-gratis.html [QSA,L,NC,R=301]


before :
Code: Select all
# DO NOT GO FURTHER IF THE REQUESTED FILE / DIR DOES EXISTS

and with proper paths and slashes (eg following the same pattern as in other phpBB RewriteRule).

Should do it ;)
Useful links :
SEO Forum || SEO Directory || SEO phpBB || Search
____________________

Liens Utiles :
Forum référencement || Annuaire référencement || Référencement phpBB || Recherche
dcz
Admin
Admin
 
Posts: 21219
Joined: Fri Apr 28, 2006 9:03 pm

Re: Need some help with 301 redirect

Postby Dangerell » Fri Nov 27, 2009 1:12 pm

Thank you very much for your quick reply, it worked like a charm ! :mrgreen:

Edit:

Following your code i did the redirects for all page numbers from 1 to 1200 which was my last page that had posts... on every forum above.. counting page numbers by 20 (20,40,60 ...1200.)

My question is, there are other redirects i must do so everything will be ok or those are all ? (Considering that those are the only forums in which i have changed the url structure)
User avatar
Dangerell
 
Posts: 10
Joined: Thu Jul 23, 2009 8:57 am

Re: Need some help with 301 redirect

Postby dcz » Fri Nov 27, 2009 4:50 pm

oh, but pagination, you could just add :
Code: Select all
    RewriteRule ^(actiune|animatie|aventuri|biografice|comedie|crima|documentare|drama|familie|fantastic|horror|indiene|istorice|mister|muzical|razboi|romanesti|romantice|sf|sport|thriller|tv|xxx)-([0-9]+)\.html$ http://www.topfilmeonline.com/filme-online-$1-$2.html [QSA,L,NC,R=301]
    RewriteRule ^(the-simpsons|heroes)-([0-9]+)\.html$ http://www.topfilmeonline.com/$1-online-$2.html [QSA,L,NC,R=301]
    RewriteRule ^filme-online-([0-9]+)\.html$ http://www.topfilmeonline.com/filme-online-gratis-$1.html [QSA,L,NC,R=301]


in addition to the other three.

Though I'm thinking that this should rather be done using php.
In phpbb_seo_class.php you could just add :
Code: Select all
      else {
         $redirect = array(
            'old_uri_of_forum_id_one' => 1,
            'old_uri_of_forum_id_xx' => xx,
         );
         if (isset($redirect[$forum_uri])) {
            $forum_id = (int) $redirect[$forum_uri];
         }
      }

after :
Code: Select all
      if ($id = @array_search($forum_uri, $this->cache_config['forum']) ) {
         $forum_id = max(0, (int) $id);
      } elseif ( $id = $this->get_url_info('forum', $forum_uri, 'id')) {
         $forum_id = max(0, (int) $id);
      }


You would just need to fill :
Code: Select all
         $redirect = array(
            'old_uri_of_forum_id_one' => 1,
            'old_uri_of_forum_id_xx' => xx,
         );


with the forum uri / forum id pairs, the forum uri being "actiune", "drama", "the-simpsons" etc. This would handle pagination too all in once, using the zero duplicate.

++
Useful links :
SEO Forum || SEO Directory || SEO phpBB || Search
____________________

Liens Utiles :
Forum référencement || Annuaire référencement || Référencement phpBB || Recherche
dcz
Admin
Admin
 
Posts: 21219
Joined: Fri Apr 28, 2006 9:03 pm

Re: Need some help with 301 redirect

Postby Dangerell » Sat Nov 28, 2009 11:29 am

I did the edits in phpbb_seo_class.php, now i can safely remove the edits i made in htaccess, right ?

One question from curiosity, how will google see those old pages... now that are two pages for same page(forum)...the old ones and the new ones.. in time google will remove the old ones or will remain as pages with duplicate titles ?

Thank you very much for your support, you definitely helped me fix my site's url issues! :D
User avatar
Dangerell
 
Posts: 10
Joined: Thu Jul 23, 2009 8:57 am

Re: Need some help with 301 redirect

Postby dcz » Sat Dec 05, 2009 8:15 am

When Google sees a 301, it drops the old url in favor to the new one, simple as that. With latest zero dupe (0.6.2), a canonical element is also added, stating once more that the new url is indeed the new one to use.
Google is usually quite fast with 301 redirect, even if they are massive.

And yes, you don't need the .htaccess modification with the php one, just make sure about the header returned, should be all right, but it's always worth checking.
Useful links :
SEO Forum || SEO Directory || SEO phpBB || Search
____________________

Liens Utiles :
Forum référencement || Annuaire référencement || Référencement phpBB || Recherche
dcz
Admin
Admin
 
Posts: 21219
Joined: Fri Apr 28, 2006 9:03 pm

Re: Need some help with 301 redirect

Postby Dangerell » Sat Dec 05, 2009 8:55 am

Thank you i've left only the php seo edits and everything worked and still works like a charm. 8)
User avatar
Dangerell
 
Posts: 10
Joined: Thu Jul 23, 2009 8:57 am

Re: Need some help with 301 redirect

Postby dcz » Sat Dec 05, 2009 9:41 am

;)
Useful links :
SEO Forum || SEO Directory || SEO phpBB || Search
____________________

Liens Utiles :
Forum référencement || Annuaire référencement || Référencement phpBB || Recherche
dcz
Admin
Admin
 
Posts: 21219
Joined: Fri Apr 28, 2006 9:03 pm


Return to phpBB mod Rewrite

 


  • Related topics
    Replies
    Views
    Last post

Who is online

Users browsing this forum: Yahoo [Bot] and 3 guests