PHPBBMODforGoogle full solution

Source: Internet
Author: User
PHPBBMODforGoogle full solution, read PHPBBMODforGoogle full solution, author: Trotter Email: trotter@kekerde.net Source: www.gbunix.com reprint please keep the document complete, indicate the source. Preface as content on the Internet grows at an astonishing rate, the search engine's

Author: Trotter
Email: trotter@kekerde.net
Source: www.gbunix.com

Reprinted please keep the document complete and indicate the source.

Preface

As the content on the Internet grows at an astonishing rate, the importance of search engines is becoming increasingly prominent. if a website wants to be better indexed by search engines, the website design is not only user-friendly, the design of Search Engine Friendly is also very important. The more content you enter the search engine page, the more likely you will find using different keywords. I have to admit that converting dynamic web page link rewriting into static link is the safest and most stable search engine-oriented optimization method. This scheme is proposed for URL redirection in the phpBB Forum system.

Solution

URL redirection is technically implemented in two ways: URL rewrite and PATH_INFO. For example.

For the transformation of the PHPBB Forum, we will introduce these two technologies respectively.

I. Use rewrite technology to implement:

Modify the phpBB Code:

Open the/uplodes/page_header.php file,

Search code:

//
// Generate logged in/logged out status
//

Previously added:

Ob_start ();
Function replace_for_mod_rewrite (& $ s)
{
$ Urlin =
Array (
"'(? "'(? "'(? "'(? "'(? "'(? "'(? "'(? "'(? "'(? "'(? );
$ Urlout = array (
"Viewforum \ 1-\ 2-\ 3.html ",
"Forum \ 1.html ",
"Forum \ 1.html ",
"Ptopic \ 1.html ",
"Ntopic \ 1.html ",
"Ftopic \ 1-\ 2-\ 3-\ 4.html ",
"Ftopic \ 1.html ",
"Ftopic \ 1-\ 2.html ",
"Ftopic \ 1.html ",
"Sutra \ 1.html ",
"Sutra \ 1.html ",
);
$ S = preg_replace ($ urlin, $ urlout, $ s );
Return $ s;
}

Open the/shortdes/page_tail.php file,

Search code:

$ Db-> SQL _close ();

Add after:

$ Contents = ob_get_contents ();
Ob_end_clean ();
Echo replace_for_mod_rewrite ($ contents );
Global $ dbg_starttime;

If your phpBB version is 2.06, open the file des/functions. php,

Search code:

If (! Empty ($ db ))
{
$ Db-> SQL _close ();
}

Add after:

If (stristr ($ url, 'http ://')){
Header ('Location: '. $ url );
Exit;
}

Finally, create a. htaccess file in the bbs Directory. the file content is:

RewriteEngine On
RewriteRule ^ forums. * index. php
RewriteRule ^ forum ([0-9] *). * viewforum. php? F = $1 & mark = topic
RewriteRule ^ viewforum ([0-9] *)-([0-9] *)-([0-9] *). * viewforum. php? F = $1 & topicdays = $2 & start = $3
RewriteRule ^ forum ([0-9] *). * viewforum. php? F = $1
RewriteRule ^ ptopic ([0-9] *). * viewtopic. php? T = $1 & view = previous
RewriteRule ^ ntopic ([0-9] *). * viewtopic. php? T = $1 & view = next
RewriteRule ^ ftopic ([0-9] *)-([0-9] *)-([a-zA-Z] *) -([0-9] *). * viewtopic. php? T = $1 & postdays = $2 & postorder = $3 & start = $4
RewriteRule ^ ftopic ([0-9] *)-([0-9] *). * viewtopic. php? T = $1 & start = $2
RewriteRule ^ ftopic ([0-9] *). * viewtopic. php? T = $1
RewriteRule ^ ftopic ([0-9] * viewtopic. php? T = $1 & start = $2 & postdays = $3 & postorder = $4 & highlight = $5
RewriteRule ^ sutra ([0-9] *). * viewtopic. php? P = $1

If your server does not support. htaccess, open the httpd. conf file and edit the part of your VM as follows:


ServerAdmin webmaster@domain.com
DocumentRoot/home1/ftp/trotter/www
ServerName www.gbunix.com
RewriteEngine On
RewriteRule ^/bbs/forums. */bbs/index. php
RewriteRule ^/bbs/forum ([0-9] *). */bbs/viewforum. php? F = $1 & mark = topic
RewriteRule ^/bbs/viewforum ([0-9] *)-([0-9] *)-([0-9] *). */bbs/viewforum. php? F = $1 & topicdays = $2 & start = $3
RewriteRule ^/bbs/forum ([0-9] *). */bbs/viewforum. php? F = $1
RewriteRule ^/bbs/ptopic ([0-9] *). */bbs/viewtopic. php? T = $1 & view = previous
RewriteRule ^/bbs/ntopic ([0-9] *). */bbs/viewtopic. php? T = $1 & view = next
RewriteRule ^/bbs/ftopic ([0-9] *)-([0-9] *)-([a-zA-Z] *) -([0-9] *). */bbs/viewtopic. php? T = $1 & postdays = $2 & postorder = $3 & start = $4
RewriteRule ^/bbs/ftopic ([0-9] *)-([0-9] *). */bbs/viewtopic. php? T = $1 & start = $2
RewriteRule ^/bbs/ftopic ([0-9] *). */bbs/viewtopic. php? T = $1
RewriteRule ^/bbs/ftopic ([0-9] * developer.html/bbs/viewtopic. php? T = $1 & start = $2 & postdays = $3 & postorder = $4 & highlight = $5
RewriteRule ^/bbs/sutra ([0-9] *). */bbs/viewtopic. php? P = $1
ErrorLog logs/gbunix.com-error_log
CustomLog logs/gbunix.com-access_log combined

If you are not using a VM, put some of the RewriteRule code in the httpd. conf file.

Note: for system security, create the robots.txt file in the bbsexample Directory. the file content is as follows:

Disallow:/your-forum-folder/sutra *. html $
Disallow:/your-forum-folder/ptopic *. html $
Disallow:/your-forum-folder/ntopic *. html $
Disallow:/your-forum-folder/ftopic * asc *. html $

Install the mod_rewrite module for apache

If apache is not installed on your server, it is easy to compile the mod_rewrite module during apache Compilation. relevant documents can be found in www.gbunix.com. If your apache has been installed and you only want to compile the mod_rewrite.so module and load it in apache, we will introduce this method below.

Use the Solaris operating system as an example:

# PATH =/usr/local/bin:/usr/sfw/bin:/usr/ccs/bin: $ PATH
# Export PATH
# Which gcc
# Which make

# Find./-name mod_rewrite.c // find the mod_rewrite.c file in the apache installation directory
# Cd PATH/to/mod_rewrite.c // enter the directory containing the mod_rewrite.c file
# Apxs-c mod_foo.c // specify the absolute path in the apache bin directory.
# Apxs-I-a-n mod_rewrite mod_rewrite.la

If there are no errors, compile a mod_rewrite.so file in your apache modules Directory.

Edit the httpd. conf file and confirm that the httpd. conf file contains the loading statement mod_rewrite.so, as shown below:

LoadModule rewrite_module modules/mod_rewrite.so

At this time, your apache should have supported rewrite.

II. implementation based on PATH_INFO:

Modify the phpBB Code:

Open the overall_header.tpl file and add the following code in the first line:

Open the config. php file and go to?> Add the following code before:

If ($ REQUEST_METHOD = "GET "){
If (strlen (getenv ('path _ info')> 1 ){
$ GET_array = array ();
$ PHP_SELF = str_replace (getenv ('path _ info'), '', $ PHP_SELF );
$ Vars = explode ('/', substr (getenv ('path _ info'), 1 ));
For ($ I = 0, $ n = sizeof ($ vars); $ I <$ n; $ I ++ ){
If (strpos ($ vars [$ I], '[]') {
$ GET_array [substr ($ vars [$ I], 0,-2)] [] = $ vars [$ I + 1];
} Else {
$ HTTP_GET_VARS [$ vars [$ I] = $ vars [$ I + 1];
}
$ I ++;
}
If (sizeof ($ GET_array)> 0 ){
While (list ($ key, $ value) = each ($ GET_array )){
$ HTTP_GET_VARS [$ key] = $ value;
}
}
}

}

If ($ REQUEST_METHOD = "POST "){
If (strlen (getenv ('path _ info')> 1 ){
$ POST_array = array ();
$ PHP_SELF = str_replace (getenv ('path _ info'), '', $ PHP_SELF );
$ Vars = explode ('/', substr (getenv ('path _ info'), 1 ));
For ($ I = 0, $ n = sizeof ($ vars); $ I <$ n; $ I ++ ){
If (strpos ($ vars [$ I], '[]') {
$ POST_array [substr ($ vars [$ I], 0,-2)] [] = $ vars [$ I + 1];
} Else {
$ HTTP_POST_VARS [$ vars [$ I] = $ vars [$ I + 1];
}
$ I ++;
}
If (sizeof ($ GET_array)> 0 ){
While (list ($ key, $ value) = each ($ POST_array )){
$ HTTP_POST_VARS [$ key] = $ value;
}
}
}

}

Open the functions. php file and go to?> Add the following code before:

Function replace_for_mod_rewrite ($ s ){

$ S = str_replace ("? ","/", $ S );
$ S = str_replace ("&", "/", $ s );
$ S = str_replace ("&", "/", $ s );
$ S = str_replace ("=", "/", $ s );
Return $ s;

}

Open the sessions. php file and use the following code to replace the previously defined append_sid () function:

Function append_sid ($ url, $ non_html_amp = false)
{
Global $ SID;


If (! Empty ($ SID )&&! Preg_match ('# sid = #', $ url )&&! Preg_match ('# sid/#', $ url )&&! Stristr ($ _ SERVER ["HTTP_USER_AGENT"], 'bot ')&&! Stristr ($ _ SERVER ["HTTP_USER_AGENT"], 'inktomi '))
{
$ Url. = (strpos ($ url ,'? ')! = False )? ($ Non_html_amp )? '&':'&'):'? '). $ SID;
}
$ Url = replace_for_mod_rewrite ($ url );
Return $ url;
}

At this point, your forum URL will map to (http://www.domain/bbs/viewtopic.php/t/4) this way.

References:

Http://www.phpbb.com/phpBB/viewtopic.php? T = 199008

Http://www.phpbb.com/phpBB/viewtopic.php? T = 137334

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.