CH & win1251 & Simple mod rewrite

phpBB2 SEO Simple mod Rewrite support forum.
This mods performs a fully static URL rewriting for phpBB.
Simple and efficient.

Moderator: Moderators

CH & win1251 & Simple mod rewrite

Postby vitok » Thu Jan 25, 2007 8:49 pm

Hallo!

I've been thinking of applying the mod to the site http://osvic.ru and do have some questions:
1) the site is in Russian, charset win1251. Shall i get any advantage from using Mixed/Advanced mod rewrite or Simple mod rewrite is the only possible choice?
2) i'm using CH 2.12. Shall i have any problems with installing mod rewrite over CH? Dcz wrote
I'll need first to work on a CH 2.16 solution (2.14 already has support for simple mod rewrite) and this can take some time since CH is almost a phpBB fork
so probably i shall not?
3) google has indexed almost all pages of the site, even with those phpBB vanilla URLs session id's. Maybe mod rewrite is not that actual in the case?

Thanxs! :wink:
vitok
 
Posts: 10
Joined: Thu Jan 25, 2007 8:09 pm

Advertisement

Postby dcz » Fri Jan 26, 2007 2:52 pm

And welcome :D

So we'll have to deal with to types of problematic here.

First CH.

So far, I don't think that more that the simple mod rewrite will work on it, and it's not even sure you won't have to change some parts of it, this is to be checked.

Then for title injection and non Latin char-set, it is possible to tweak the format_url function a bit so that it will only inject the Latin chars in the URL.

This would allow this kind of title injection :

Latin_Word Cyrillic_Word = >latin-word


This is only an useful thing to do if you plan to often use Latin char-set words, like it could be the case if you forum was talking a bout ccs design for example.
It's a good thing for projects that will deal with technical words, things like that.

If not, the simple mod rewrite is the one to use, no need to inject anything in url we cannot ;)

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

Postby vitok » Fri Jan 26, 2007 3:18 pm

dcz wrote:This is only an useful thing to do if you plan to often use Latin char-set words

No, i do not plan this... :)

Some sites (e.g. ru.wikipedia.org) use cyrillic letters in their url's. Still i don't think that's smth i want. Or, better to say, i do not think this is smth that robots will be happy to see on the site :D Or maybe i'm mistaken?

Thanks a lot for your answer. I really can't understand how you manage to answer that many questions that fast... I'll try simple mod rewrite very soon... :wink:
vitok
 
Posts: 10
Joined: Thu Jan 25, 2007 8:09 pm

Postby vitok » Wed Jan 31, 2007 4:58 pm

Ok, i've tried the mod and it looks great! :D Still i had to make some changes in the code. Futher i briefly describe what i've done. It would be great if you find several minutes to look the changes through and to comment them in case i've spoiled smth ;)

1) i have CH installed => had to change includes/class_config.php the way you've described in phpBB-SEO-Simple-mod-Rewrite_V_0.0.2_CH_Edition . The replacement caused some problems with attach_mod and cache, so i used
Code: Select all
if (!defined('IN_ADMIN') && !defined('IN_LOGIN') && !( strstr($basename, 'includes/') || strstr($basename, 'attach_mod/') || strstr($basename, 'cache/') || strstr($basename, 'language/')) )
instead of
Code: Select all
if (!defined('IN_ADMIN') && !defined('IN_LOGIN') && !( strstr($basename, 'includes/') || strstr($basename, 'language/')) )

2) i changed .htaccess as you describe in the same file
3) as far as i cannot insert cyrillic chars in the urls and i have only two main categories and few forums, i've decided to translate forum names manually and to use urls e.g.
Code: Select all
http://localhost/school-abitu/moscow-state-university/article7029.html
instead of
Code: Select all
http://localhost/article7029.html
for my topics where school-abitu is one of my categories and moscow-state-university is one of my forums. Thus i added .* in rewrite_rules concerning topics & posts.

4) 3) caused problems with images and urls (because of two additional slashes), so i had to add strings
Code: Select all
RewriteRule ^.*templates/(.*)$ templates/$1 [QSA,L]
RewriteRule ^.*images/(.*)$ images/$1 [QSA,L]
in htaccess file and to write
Code: Select all
return 'http://localhost/' . $url;
instead of
Code: Select all
return $url;
in append_sid function (sessions.php)

5) i defined array rubr in your class phpbb_seo
Code: Select all
$this->rubr2 = 'school-abitu/';
$this->rubr=array(
...
56 => $this->rubr2.'moscow-state-university',
...
);

6) instead of
Code: Select all
'U_VIEW_TOPIC' => $config->url($this->requester_topics, $this->extra_parms + array(POST_TOPIC_URL => ((!empty($row['topic_moved_id']) && empty($this->extra_parms)) ? $row['topic_moved_id'] : $row['topic_id'])), true),
in class_topics.php i used
Code: Select all
'U_VIEW_TOPIC' => $config->url($this->requester_topics, $this->extra_parms + array(POST_TOPIC_URL => ((!empty($row['topic_moved_id']) && empty($this->extra_parms)) ? $row['topic_moved_id'] : $row['topic_id'])) + array(POST_FORUM_URL => $row['forum_id']), true),
to make it possible to learn the forum id from topics url

7) finally i replaced
Code: Select all
$this->url = $this->seo_static['topic'] . $this->get_vars[POST_TOPIC_URL] . $this->start . $this->seo_ext['topic'];
with
Code: Select all
$this->url = $this->rubr[$this->get_vars[POST_FORUM_URL]] . '/' . $this->seo_static['topic'] . $this->get_vars[POST_TOPIC_URL] . $this->start . $this->seo_ext['topic'];
in your viewtopic() function and added the line
Code: Select all
unset($this->get_vars[POST_FORUM_URL]);


That's all :)

I still have some problems with navigation and ppages :) but i guess i can solve them myself)

Thanks a lot for your great work and for your help, dcz :!:
vitok
 
Posts: 10
Joined: Thu Jan 25, 2007 8:09 pm

Postby dcz » Wed Jan 31, 2007 6:26 pm

Great :D

So you used a static array to always know the forum titles, brilliant.

Have you seen the way I modded the download mod ?
It was actually very handy with the OO approach, and because the Download mod is always grabbing all category titles.

While working on phpBB3, I was actually thinking about implementing a cache for forum titles, kind of the way you did, but with auto updating features.

I don't know how it will end up, but the idea would be great to add folder injection to phpBB.

How did you deal with absolute linking ? base href of subsilver.cfg ?

I am interested into providing solutions for Category hierarchy, but miss time at the moment, so if you like we can collaborate a bit on this.

You could PM me your phpbb_seo_class.php, and I'll drop notes in the code and give you hints (especially for the p param etc), what do you think ?

You could end up releasing a pretty nice mod here ;)

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

Postby vitok » Fri Feb 02, 2007 3:14 pm

dcz wrote:While working on phpBB3, I was actually thinking about implementing a cache for forum titles, kind of the way you did, but with auto updating features.

Sounds great ;)

dcz wrote:How did you deal with absolute linking ? base href of subsilver.cfg ?

My append_sid function returns (PHPBB_URL . $url) instead of ($url). And that's it, I quess...

dcz wrote:I am interested into providing solutions for Category hierarchy, but miss time at the moment, so if you like we can collaborate a bit on this.

It might be nice...

dcz wrote:You could PM me your phpbb_seo_class.php, and I'll drop notes in the code and give you hints (especially for the p param etc), what do you think ?

That's what I'll do right now :D
It seems to me that i've solved my problems with navi and ppages. But I'll appreciate any comments and suggestions!

As for me I like it when it's possible to just delete the end of url in the browser and to see the directory I'm in. That is to get from
Code: Select all
http://www.phpbb-seo.com/boards/posting.php
to
Code: Select all
http://www.phpbb-seo.com/boards/

So I made it this way in the phpbb_seo class and in htaccess. If it's possible look through htaccess please cause I'm not sure that I use "!" in the rules correctly (though it works fine).

It seems that I need to make robots.txt... And to insert pagination into urls as you write it somewhere here. And to apply metatags mod. And not to forget about google map... Huh, the evening's going to be quite interesting ;)
vitok
 
Posts: 10
Joined: Thu Jan 25, 2007 8:09 pm

Postby dcz » Fri Feb 02, 2007 3:26 pm

All right :D

Will look at this.

About the the end of url in the browser, you can only get rid of it for the index.php, the example you posted would not allow other url to work in the same folder, like search.php etc ...

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

Postby vitok » Fri Feb 02, 2007 3:43 pm

dcz wrote:About the the end of url in the browser, you can only get rid of it for the index.php, the example you posted would not allow other url to work in the same folder, like search.php etc ...

Maybe my example wasn't good enough. I meant this:

Code: Select all
http://localhost/school-abitu/edinyi-gos-exam-ege-nn59/article7087.html

(it's a topic) vs
Code: Select all
http://localhost/school-abitu/edinyi-gos-exam-ege-nn59/
(it's a forum)
search.php works fine ;)
vitok
 
Posts: 10
Joined: Thu Jan 25, 2007 8:09 pm

Postby dcz » Fri Feb 02, 2007 4:01 pm

I'm even more confused here.

You're just saying that the forum url is a full url with id and thus works ?

Like http://www.phpbb-seo.com/boards/simple-mod-rewrite/ ?

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

Postby vitok » Fri Feb 02, 2007 8:42 pm

Dcz, thanks a lot for your PMs!
Code: Select all
$current_template_images = PHPBB_URL . $current_template_path . "/images";

I just didn't know where to look for this :oops:
So it's really nice that you pointed out how to deal with absolute urls without editing htaccess :wink:
I will truly have to change urls here and there but that's not a problem.
vitok
 
Posts: 10
Joined: Thu Jan 25, 2007 8:09 pm

Postby dcz » Sat Feb 03, 2007 10:00 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: 21291
Joined: Fri Apr 28, 2006 9:03 pm

Postby vitok » Sun Feb 04, 2007 12:13 am

Dcz, to deal with absolute linking of images and files I had to make some more changes. Here they are:

In class_user.php
Code: Select all
function img($key)
{
global $images, $config;
return !empty($key) && isset($images[$key]) ? $config->root . $images[$key] : (eregi('^(ht|f)tp:', $key) ? $key : (@file_exists(@phpbb_realpath($config->root . $key)) ? $config->root . $key : './' .$key));
}

==>
Code: Select all
function img($key)
{
global $images, $config;
return !empty($key) && isset($images[$key]) ? $images[$key] : (eregi('^(ht|f)tp:', $key) ? $key : (@file_exists(@phpbb_realpath($config->root . $key)) ? $config->root . $key : './' .$key));
}


In phpbb_seo_class.php i added

Code: Select all
$board_config['smilies_path'] = PHPBB_URL .$board_config['smilies_path'];
$board_config['avatar_gallery_path'] = PHPBB_URL .$board_config['avatar_gallery_path'];


Also edited templates a little. In particular used
Code: Select all
{PHPBB_URL}/{postrow.attach.cat_thumb_images.IMG_THUMB_SRC}
instead of
Code: Select all
{postrow.attach.cat_thumb_images.IMG_THUMB_SRC}
in viewtopic_attach_body.tpl.

In class_topics.php

Code: Select all
$pagination = new pagination($this->requester_topics, array(POST_TOPIC_URL => $row['topic_id']) + $this->extra_parms, 'start');

==>
Code: Select all
$pagination = new pagination($this->requester_topics, array(POST_TOPIC_URL => $row['topic_id']) + array(POST_FORUM_URL => $row['forum_id']) + $this->extra_parms, 'start');


In viewtopic.php

Code: Select all
$pagination = new pagination('viewtopic', array(POST_TOPIC_URL => $topic_id, 'postdays' => $post_days, 'postorder' => $post_order, 'highlight' => $highlight));

==>
Code: Select all
$pagination = new pagination('viewtopic', array(POST_TOPIC_URL => $topic_id, POST_FORUM_URL => $forum_id, 'postdays' => $post_days, 'postorder' => $post_order, 'highlight' => $highlight));

(last two make pagination display correctly and are not about linking ;))

Now I can use htaccess you've sent me!)
vitok
 
Posts: 10
Joined: Thu Jan 25, 2007 8:09 pm

Postby vitok » Sun Feb 04, 2007 12:22 am

Now about Zero duplicate... I do certainly need the mod :D
So I used
Code: Select all
// www.phpBB-SEO.com SEO TOOLKIT BEGIN
$start_seo = _read('start', TYPE_INT);
$ppage_seo = _read('ppage', TYPE_INT);
if ($start_seo) $start_seo = '-' . $start_seo; else $start_seo = '';
if ($ppage_seo) $ppage_seo = '-' . $ppage_seo; else $ppage_seo = '';
$forum_id_seo = ($forum_id) ? ($phpbb_seo->seo_delim['forum'] . $forum_id) : '';
$uri = $phpbb_seo->seo_req_uri();
$phpbb_seo->seo_start( $start_seo, $board_config['topics_per_page'] );
$phpbb_seo->page_url = $phpbb_seo->seo_url['forum'][$forum_id] . $forum_id_seo . $ppage_seo . $start_seo . $phpbb_seo->seo_ext['forum'];
$phpbb_seo->seo_cond(!$userdata['session_logged_in'] && (strpos($uri, "sid=" ) !== FALSE ));
$topicday_redir = empty($_POST['topicdays']) && empty($_GET['topicdays']);
if ($_GET['topicdays'] == 0  || $_POST['topicdays'] == 0 ) {
   $topicday_redir = TRUE;
}
if ( $phpbb_seo->do_redir || ( ($mark_read == '') && $topicday_redir && ( strpos($uri, $phpbb_seo->page_url) === FALSE ) ) ) {
   $phpbb_seo->seo_redirect( PHPBB_URL . $phpbb_seo->page_url );
}
// www.phpBB-SEO.com SEO TOOLKIT END

in index.php and

Code: Select all
// www.phpBB-SEO.com SEO TOOLKIT BEGIN
$start_seo = _read('start', TYPE_INT);
if ($start_seo) $start_seo = '-' . $start_seo; else $start_seo = '';
$forum_id_seo = ($forum_id) ? ($phpbb_seo->seo_delim['forum'] . $forum_id) : '';

$uri = $phpbb_seo->seo_req_uri();
$postorder_redir = empty($_POST['postorder']) && empty($_GET['postorder']);
if ($_GET['postorder'] == 'asc'  || $_POST['postorder'] == 'asc' ) {
   $postorder_redir = TRUE;
}
$phpbb_seo->seo_start( $start_seo, $board_config['posts_per_page'] );
$phpbb_seo->page_url = $phpbb_seo->seo_url['forum'][$forum_id] . $forum_id_seo . $phpbb_seo->seo_ext['forum'] . $phpbb_seo->seo_static['topic'] . $topic_id . $start_seo . $phpbb_seo->seo_ext['topic'];

//$phpbb_seo->page_url = $phpbb_seo->seo_static['topic'] . $topic_id . $phpbb_seo->start . $phpbb_seo->seo_ext['topic'];
$phpbb_seo->seo_cond(!$userdata['session_logged_in'] && ( strpos($uri, "sid=" ) !== FALSE ) );
if ( $phpbb_seo->do_redir || ( $postorder_redir &&  strpos($uri, 'watch=') === FALSE && strpos($uri, $phpbb_seo->page_url) === FALSE )  ) {
   $phpbb_seo->seo_redirect( PHPBB_URL . $phpbb_seo->page_url . ( ( $post_id ) ? "#$post_id" : "" ) );
}
// www.phpBB-SEO.com SEO TOOLKIT END

in viewtopic.php. Is that alright or I have to change smth else?

And again THANKS a bunch for your help!! :)
vitok
 
Posts: 10
Joined: Thu Jan 25, 2007 8:09 pm

Postby dcz » Sun Feb 04, 2007 1:31 pm

Well, I cannot really tel for CH, if it's enough I mean, but it looks like you got the idea ;)

There is just on thing about the pagination :

The $phpbb_seo->seo_start method is as well making sure the start param is acceptable, it will make sure the page is a page that exists, according to the boards settings.

For example if you set topics_per_page to be 15, and if start in url is for example 35, the url will be redirected to the second page, start = 30 ;)

The function is not designed to allow more than one pagination param, a simple tweak would be to implement an additional copy of the same method in phpbb_seo_class.php :

Code: Select all
   /**
   * check ppage var consistency
   */
   function seo_ppage($ppage = 0, $limit = 0) {
      if ($limit > 0) {
         $start = ( is_int( $ppage/$limit ) ) ? $ppage : intval($ppage/$limit)*$limit;
         $this->ppage = ( $ppage > 0  ) ? $this->seo_static['start'] . $ppage : '';
      } else {
         $this->ppage = ( $ppage > 0  ) ? $this->seo_static['start'] . $ppage : '';
      }
   }


You'd need as well to add :
Code: Select all
var    $ppage = '';

in the phpbb_seo class, as well as :
Code: Select all
$this->ppage = '';


In the constructor.

Then, what you wrote above would become :

For index.php

Code: Select all
// www.phpBB-SEO.com SEO TOOLKIT BEGIN
$uri = $phpbb_seo->seo_req_uri();
$phpbb_seo->seo_cond(!$userdata['session_logged_in'] && (strpos($uri, "sid=" ) !== FALSE ));
if ($forum_id) { // we're in the forum case
   // these two are most likely already knew at this stage in the regular code
   // but I can't tell without running CH
   $start_seo = _read('start', TYPE_INT);
   $ppage_seo = _read('ppage', TYPE_INT);
   $phpbb_seo->seo_start( $start_seo, $board_config['topics_per_page'] );
   // here you need to replace $board_config['topics_per_page'] with this
   // forum's ppage setting, there must be a var for this in CH code.
   // not $board_config['topics_per_page'] ;)
   $phpbb_seo->seo_ppage( $ppage_seo, $board_config['topics_per_page'] );
   $phpbb_seo->page_url = $phpbb_seo->seo_url['forum'][$forum_id] . $phpbb_seo->seo_delim['forum'] . $forum_id . $phpbb_seo->ppage . $phpbb_seo->start . $phpbb_seo->seo_ext['forum'];
   $topicday_redir = empty($_POST['topicdays']) && empty($_GET['topicdays']);
   if ($_GET['topicdays'] == 0  || $_POST['topicdays'] == 0 ) {
      $topicday_redir = TRUE;
   }
   if ( $phpbb_seo->do_redir || ( ($mark_read == '') && $topicday_redir && ( strpos($uri, $phpbb_seo->page_url) === FALSE ) ) ) {
      $phpbb_seo->seo_redirect( PHPBB_URL . $phpbb_seo->page_url );
   }
} else { // forum index call, juste check the index.php usage
   // I am not sure CH would still use this var for marcking forums
   $mark_use = ($userdata['session_logged_in']) ? $mark_read : '';
   if (!empty($phpbb_seo->seo_static['index'])) {
      $phpbb_seo->seo_cond(( $mark_use == '' &&  strpos($uri, $phpbb_seo->seo_static['index']) === FALSE ), TRUE);
   } else {
      $phpbb_seo->seo_cond(( $mark_use == '' &&  strpos($uri, "index.$phpEx") !== FALSE ), TRUE);
   }
   if ( $phpbb_seo->do_redir) {
      $phpbb_seo->seo_redirect(PHPBB_URL . $phpbb_seo->seo_static['index']);
   }
}
// www.phpBB-SEO.com SEO TOOLKIT END


So you'll have to work a bit on finding the correct var for this forum's ppage param. As well the $mark_read var could be different in CH.

Note that this way, the ppage param just cannot be something else than default.
We could add a user logged in check in the ppage method to allow special ppage settings for logged user.

So let's see how this work, and everything will be obvious for viewtopic.php ;)

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

Postby vitok » Sun Feb 04, 2007 5:12 pm

Thanks for seo_ppage function ;)

dcz wrote:these two are most likely already knew at this stage in the regular code

It seems to me they are not. I can find the strings
Code: Select all
$topics = new topics();
$topics->read($forum_id);

only somewhere in the middle of index.php and

Code: Select all
$this->parms = array_merge($this->parms, array(
'start' => _read('start', TYPE_INT),
'ppage' => _read('ppage', TYPE_INT),
'topicdays' => _read('topicdays', TYPE_INT),
'sort' => _read('sort', TYPE_NO_HTML, '', array('' => '') + $this->sort_fields),
'order' => strtoupper(_read('order', TYPE_NO_HTML, '', array_flip(array('', 'asc', 'ASC', 'desc', 'DESC')))),
));


is the part of read function in class_topics.php.

dcz wrote:So you'll have to work a bit on finding the correct var for this forum's ppage param. As well the $mark_read var could be different in CH.

Ok, I understand. I'll check on this...

I've finally uploaded everything on www.osvic.ru
I'm not just looking happy, I am happy!! :D
vitok
 
Posts: 10
Joined: Thu Jan 25, 2007 8:09 pm

Next

Return to phpBB2 Simple mod rewrite

 


  • Related topics
    Replies
    Views
    Last post

Who is online

Users browsing this forum: No registered users and 4 guests