Adding own url-rewrites

phpBB SEO Premod for phpBB3 support forum.
This premodded version of phpBB3 includes the three different type of URL rewriting for phpBB3 by phpBB SEO. It comes with several other Search Engine Optimization mods installed.

Moderator: Moderators

Adding own url-rewrites

Postby wolkenkrieger » Fri Jun 19, 2009 12:37 am

Where and/or how can in add custom rewrites (impressum.php -> impressum.html, arcade.php -> /spielhalle/arcade.html, ppshop.php -> /boardshop/shop.html, ...)?
wolkenkrieger
PR0
PR0
 
Posts: 77
Joined: Sat Nov 03, 2007 4:49 pm

Advertisement

Re: Adding own url-rewrites

Postby dcz » Fri Jun 19, 2009 7:18 am

If only for a page, the easiest would be just to hard code these while they are passing through append_sid(), since chances are great that you do it once and for all, while passing the link to the template.

Then, add the corresponding rewriterule for each new case :
Code: Select all
RewriteRule ^impressum\.html$ /impressum.php [QSA,L,NC]


Or you can easily add some custom rewriting in phpbb_seo/includes/setup_phpbb_seo.php, the most basic example with ppshop.php would be to add :
Code: Select all
      $this->rewrite_method[$phpbb_root_path]['ppshop'] = 'ppshop';
      $this->file_hbase['ppshop'] = $this->seo_path['phpbb_url'];

before :
Code: Select all
      // Let's make sure that settings are consistent
      $this->check_config();

And then :
Code: Select all
   /**
   * URL rewritting for ppshop.php
   * @access private
   */
   function ppshop() {
      $this->path = $this->seo_path['phpbb_url'] . 'boardshop/';
      $this->url = 'shop.html';
      return;
   }

After :
Code: Select all
      // Let's make sure that settings are consistent
      $this->check_config();
   }
   // Here start the add-on methods

This would work assuming that ppshop.php is within the phpBB install directory, since we define the phpbb_seo::rewrite_method with $phpbb_root_path in this example for ppshop.php, but you could use another path, relative to $phpbb_root_path if you put it elsewhere.
Since you involve a virtual directory (boardshop/), you need to as well define an entry for ppshop in the phpbb_seo::file_hbase array, providing with the full url from root to where the physical ppshop.php stands.
Then the rewriting method is the simplest case, no variable filtering and no pagination, but extra variable passed to append_sid() while generating the url would still work and passed to the rewritten url (boardshop/shop.html?get=value)
Note that the phpbb_seo::path defined in phpbb_seo::ppshop must match the rewritten location you want.
It is set two time in most rewriting method, since when we conditionally rewrite, after testing that the proper GET variable we need where sent through append_sid(), we could fall back to the case where the same script must not be rewritten (special case filtered), so the second phpbb_seo::path definition is the path that will be used when the link is not rewritten, it can be different if you for example use virtual root, or a virtual directory like in this example.

Ultimately, you would need an extra rewriterule for this new case :
Code: Select all
RewriteRule ^boardshop/shop\.html$ /ppshop.php [QSA,L,NC]

The QSA flag is the one that will make boardshop/shop.html?get=value to still work.

No need to mention, only url built with append_sid() and the proper path (the same as defined in the phpbb_seo::rewrite_method array) will be rewritten.

Have fun playing, and do not hesitate to ask for more details ;)

++
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: 21376
Joined: Fri Apr 28, 2006 9:03 pm

Re: Adding own url-rewrites

Postby wolkenkrieger » Sat Jun 20, 2009 9:42 am

dcz wrote:and do not hesitate to ask for more details ;)


If you say so ... :D

How can i change this http://www.bulldogboard.eu/mitglieder/Administrator/topics/seite30.html to http://www.bulldogboard.eu/mitglieder/Administrator/beitraege/seite30.html

I found this in phpbb_seo_class.php

Code: Select all
$user_id = !empty($this->get_vars['author_id']) ? $this->get_vars['author_id'] : ( isset($this->seo_url['username'][rawurldecode(@$this->get_vars['author'])]) ? $this->seo_url['username'][rawurldecode($this->get_vars['author'])] : 0);
      if ( $user_id && isset($this->seo_url['user'][$user_id]) ) {
         // Filter default params
         $this->filter_get_var($this->phpbb_filter['search']);
         $this->{$this->paginate_method['user']}($this->seo_ext['user']);
         $sr = (@$this->get_vars['sr'] == 'topics' ) ? 'topics' : 'posts';
         $this->url = $this->seo_url['user'][$user_id] . $this->seo_delim['sr'] . $sr . $this->start;
         unset($this->get_vars['author_id'], $this->get_vars['author'], $this->get_vars['sr']);
         return;
      } elseif ( $this->seo_opt['profile_noids'] && !empty($this->get_vars['author']) ) {
         // Filter default params
         $this->filter_get_var($this->phpbb_filter['search']);
         $this->rewrite_pagination_page();
         $sr = (@$this->get_vars['sr'] == 'topics' ) ? '/topics' : '/posts';
         $this->url = $this->seo_static['user'] . '/' . $this->seo_url_encode($this->get_vars['author']) . $sr . $this->start;
         unset($this->get_vars['author'], $this->get_vars['author_id'], $this->get_vars['sr']);
         return;


Is this the only point to change this to a more german style or are there other points to do that?

I want to make my URLs more german and in the moment topics is the only word, that still is in english :)

[Edit]

Yust in this moment i see, that the attachements are still pointed to ressources and images to image. The german way wold be dateianhaenge and bild...



btw. it would be a nice gimmick for the next version of this great mod if it comes in a multilingual way for the rewritten urls :wink:
wolkenkrieger
PR0
PR0
 
Posts: 77
Joined: Sat Nov 03, 2007 4:49 pm

Re: Adding own url-rewrites

Postby dcz » Sat Jun 20, 2009 9:51 am

phpBB3-SEO-Premod_V_3.0.5.txt wrote:=> The first setting to do is to select which static part to use in your URLs.

To do so, you can override default values in phpbb_seo/includes/setup_phpbb_seo.php, still before :

Code: Select all
      // Let's make sure that settings are consistent
      $this->check_config();


EXAMPLES :
__________

Code: Select all
// => the-team :   
      $this->seo_static['leaders'] = 'my-team'; // instead of the default "the-team"


// => announces :
$this->seo_static['global_announce'] = 'announcements'; // instead of the default "announces"

Code: Select all
// => Active topics :
      $this->seo_static['atopic'] = 'important-topics'; // instead of the default "active-topics"


Code: Select all
// => Unaswered :
      $this->seo_static['utopic'] = 'not-answered'; // instead of the default "unanswered"


Code: Select all
// => Newposts :
      $this->seo_static['npost'] = 'new-messages'; // instead of the default "newposts"


=> As well as for (and the same way) :
Code: Select all
forum ($this->seo_static['forum']), topic ($this->seo_static['topic']), post ($this->seo_static['post']), member ($this->seo_static['member']), groups ($this->seo_static['group']), attachments virtual directory ($this->seo_static['file_index'], read the comments in the file for more attachments customizing) and virtual folder pagination ($this->seo_static['page'])


So for topics, use :
Code: Select all
      $this->seo_static['topic'] = 'beitraege';


And do not forget that you will then need to update your .htaccess, and to keep a rewriterule to properly redirect the "topic" urls in case your forum was already index. In you case, it would be something like :
Code: Select all
# OLD TOPIC
RewriteRule ^[a-z0-9_/-]*topic([0-9]+)/?(seite([0-9]+)\.html)?$ viewtopic.php?t=$1&start=$3 [QSA,L,NC]

to add at the end of your .htaccess with proper paths and slashes ;)
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: 21376
Joined: Fri Apr 28, 2006 9:03 pm

Re: Adding own url-rewrites

Postby wolkenkrieger » Sat Jun 20, 2009 10:07 am

Ah! This is really cool :)
wolkenkrieger
PR0
PR0
 
Posts: 77
Joined: Sat Nov 03, 2007 4:49 pm

Re: Adding own url-rewrites

Postby wolkenkrieger » Sat Jun 20, 2009 10:43 am

Sorry :oops:

I try to get this Rewriterule to work:

Code: Select all
RewriteRule ^mitglieder/([^/]+)/(themen|beitraege)/?(seite([0-9]+)\.html)?$ /search.php?author=$1&sr=$2&start=$4 [QSA,L,NC]


The original one is
Code: Select all
RewriteRule ^member/([^/]+)/(topics|posts)/?(page([0-9]+)\.html)?$ /search.php?author=$1&sr=$2&start=$4 [QSA,L,NC]


But i don't get topics to themen and posts to betraege. Member to mitglieder still works fine.

I think, the "problem" is here:
Code: Select all
$sr = (@$this->get_vars['sr'] == 'topics' ) ? '/topics' : '/posts';
         $this->url = $this->seo_static['user'] . '/' . $this->seo_url_encode($this->get_vars['author']) . $sr . $this->start;


Because these are the only lines of code where "/topics" and "/posts" are hardcoded and not overwritten by $seo_static - variables.
wolkenkrieger
PR0
PR0
 
Posts: 77
Joined: Sat Nov 03, 2007 4:49 pm

Re: Adding own url-rewrites

Postby dcz » Sat Jun 20, 2009 12:04 pm

Well, you can't change these like this, because the values posts and topics are hard coded in search.php.

To do it, you would additionally need to change these in search.php, but I don't think it's this important.
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: 21376
Joined: Fri Apr 28, 2006 9:03 pm

Re: Adding own url-rewrites

Postby Laurent85 » Tue Jul 21, 2009 9:28 pm

Hi,

I go further this topic because I took all my code lines in it : )

I did what you advise in setup_phpbb_seo for static url and it works well and my new url is ok and well rewritten on link , but when I do it another time the second url is rewritten only if I write in my browser but not on the direct link : it stays page.php

the code I used is

Code: Select all
   /// Arcade list rewriting /////////////
      $this->rewrite_method[$phpbb_root_path]['arcade_list'] = 'arcade_list';    
      $this->file_hbase['arcade_list'] = $this->seo_path['phpbb_url'];
     $this->rewrite_method[$phpbb_root_path]['arcade_topplayers'] = 'arcade_topplayers';      
      $this->file_hbase['arcade_topplayers'] = $this->seo_path['phpbb_url'];
     ///end arcadelist
      // Let's make sure that settings are consistent
      $this->check_config();
   }
   // Here start the add-on methods
   /**
   *
   */
   //arcadelist//
   function arcade_list() {
      $this->path = $this->seo_path['phpbb_url'] . '';
      $this->url = 'arcade.html';
      return;
   }
   function arcade_topplayers() {
      $this->path = $this->seo_path['phpbb_url'] . '';
      $this->url = 'stats-players.html';
      return;


So it ok for arcade.html and for stats-players.html : it works only if when I type it
another question do we need to put a new line in robot txt after this change ?
User avatar
Laurent85
PR1
PR1
 
Posts: 186
Joined: Mon Feb 18, 2008 11:33 pm

Re: Adding own url-rewrites

Postby wolkenkrieger » Wed Jul 22, 2009 1:12 pm

Generally it would be very cool, if we can get "ready made" rewrites for Arcade and Gallery (like the ready mades for the portal). :D
wolkenkrieger
PR0
PR0
 
Posts: 77
Joined: Sat Nov 03, 2007 4:49 pm

Re: Adding own url-rewrites

Postby Nafania » Fri Jul 24, 2009 10:33 am

What about parent for parent? Can i add more than one parent for some url?
For example i have following structure: category -> forum -> subforum -> topic
Can i receive urls like http://mysite.com/category/forum/subforum/topic.html or http://mysite.com/forum/subforum/topic.html ?
Sorry for my english.
Nafania
 
Posts: 1
Joined: Fri Jul 24, 2009 10:29 am

Re: Adding own url-rewrites

Postby SeO » Fri Jul 24, 2009 3:30 pm

Laurent85 wrote:I did what you advise in setup_phpbb_seo for static url and it works well and my new url is ok and well rewritten on link , but when I do it another time the second url is rewritten only if I write in my browser but not on the direct link : it stays page.php


If you're rewriting a script called page.php, then you must use "page" to fill the rewrite_method array :
Code: Select all
$this->rewrite_method[$phpbb_root_path]['page'] = 'name_of_the_method_to_use';


This post as well contain interesting info about all this : SEO for Bugtracker
SeO
Admin
Admin
 
Posts: 6334
Joined: Wed Mar 15, 2006 9:41 pm


Return to phpBB SEO Premod

 


  • Related topics
    Replies
    Views
    Last post

Who is online

Users browsing this forum: No registered users and 19 guests