Implement vbb URL static by yourself

Source: Internet
Author: User
Tags vbulletin

You only need to make a simple modification to achieve static vbb URL. Of course, the server must support the rewrite function.
The Forum version is vbulletin v3.6.8 Standard Edition.
------------------------- Step 1 ---------------------------
-------------------------------------------------
Find:
------------------------------------------------

PHP code:
 
 
  1. function print_output($vartext, $sendheader = true) 
  2.     global $pagestarttime, $querytime, $vbulletin; 
  3.     global $vbphrase, $stylevar; 
  4.  
  5.     if ($vbulletin->options['addtemplatename']) 
  6.     {   

----------------------------------------------------------
Changed:
---------------------------------------------------------

PHP code:
 
 
  1. //###################################### ###
  2. // Add two functions to start
  3. Function rewrite_forum ($ extra1, $ sid, $ fid, $ order, $ page = 0, $ extra2 = '')
  4. {
  5. Return '<A'. stripslashes ($ extra1). 'href = "F-'. ($ Sid? Substr ($ Sid, 0, 32): 0). '-'. $ FID. '-'. ($ order? $ Order: 0). '-'. ($ page? $ Page: 1). '.html "'. stripslashes ($ extra2).'> ';
  6. }
  7. Function rewrite_thread ($ extra1, $ Sid, $ tid, $ page = 0, $ extra2 = '')
  8. {
  9. Return '<A'. stripslashes ($ extra1). 'href = "T-'. ($ Sid? Substr ($ Sid, 0, 32): 0). '-'. $ tid. '-'. ($ page? $ Page: 1). '.html "'. stripslashes ($ extra2).'> ';
  10. }
  11. // Add two functions to end
  12. //###################################### ###
  13. Function print_output ($ vartext, $ sendheader = true)
  14. {
  15. Global $ pagestarttime, $ querytime, $ vbulletin;
  16. Global $ vbphrase, $ stylevar;
  17. //###################################### ###
  18. // Add a program to start
  19. $ Searcharray [] = "/\ <a (. *) href \ = \" forumdisplay \. php \? (S \ = (.*))? F \ = (\ d +) (& amp; order \ = (asc | desc ))? (& Amp; page \ = (\ d + ))? \ "([^ \>] *) \>/E ";
  20. $ Replacearray [] = "rewrite_forum ('\ 1',' \ 3', '\ 4',' \ 6', '\ 8 ', '\ 9 ')";
  21.  
  22. $ Searcharray [] = "/\ <a (. *) href \ = \" showthread \. php \? (S \ = (.*))? T \ = (\ d +) (& amp; page \ = (\ d + ))? \ "([^ \>] *) \>/E ";
  23. $ Replacearray [] = "rewrite_thread ('\ 1',' \ 3', '\ 4',' \ 6', '\ 7 ')";
  24. $ Vartext = preg_replace ($ searcharray, $ replacearray, $ vartext );
  25. // Add the program to end
  26. //###################################### ###
  27. If ($ vbulletin-> options ['addtemplatename'])
  28. {

-------------------------------------------------

 

If you want to rewrite archive at the same time, make the following changes:

 

------------------------------------------------

 

Find the following statement in archive/index. php:

 

--------------------------------------------

 

PHP code:
 
 
  1. if (SLASH_METHOD AND strpos($archive_info , '/archive/index.php/') === false) 
  2.     exec_header_redirect($vbulletin->options['bburl'] . '/archive/index.php/'); 
  3. }   

-----------------------------
Change
----------------------------------------------------------

PHP code:
 
 
  1. if (SLASH_METHOD AND strpos($archive_info , '/archive/') === false) 
  2.     exec_header_redirect($vbulletin->options['bburl'] . '/archive/'); 
  3. }   

------------------------- Step 2 ---------------------------
-----------------------------------------------------
Add the file ". htaccess" to the root directory of the forum, which contains the following content:
-----------------------------------------------------

Code:
 
 
 
  1. RewriteEngine On
  2. # Modify "/vbb" to your forum directory address. If the program is placed in the root directory, change "/vbb" "/"
  3. RewriteBase/vbb
  4. RewriteRule ^ f-([0-9a-z] +)-([0-9] +)-(0 | asc | desc)-([0-9] + )\. html $ forumdisplay. php? S = $1 & f = $2 & order = $3 & page = $4
  5. RewriteRule ^ t-([0-9a-z] +)-([0-9] +)-([0-9] +) \. html $ showthread. php? S = $1 & t = $2 & page = $3
  6. RewriteRule ^ archive/(f | t)-[0-9] + \. html) $ archive/index. php? $1

---------------------------------------------------
Known bugs,
In the topic paging menu of forumdisplay. php;
In the quick paging link of the forumdisplay. php topic list;
In the theme paging menu of showthread. php;
Some dynamic pages are not overwritten, but the actual use is not affected.
An error occurred while rewriting archive.
If you have any concerns about this Bug, you can only rewrite archive. In this way, you only need to modify archive/index. A little modification in php (the same method), without having to modify the functions. PHP file, and put ". put the htaccess file in the archive folder, and then in ". htaccess is retained only:
-----------------------------------------------------

Code:
 
 
  1. RewriteEngine On
  2. # Modify "/vbb" to your forum directory address. If the program is placed in the root directory, change "/vbb" to "/archive"
  3. RewriteBase/vbb/archive
  4. RewriteRule ^ (f | t)-[0-9] + \. html) $ index. php? $1

---------------------------------------------------
In this way, you can enable the archive function to improve the search engine performance for your forum.
-------------------------------------------------
Obviously, my change method is too low, because this is the first time I write a rewrite statement, and I have some knowledge about regular expressions. However, I am very familiar with VBB code. I think VBB's programming style is good. It is a good choice to learn PHP4, but if you want to learn PHP5, WBB3 code is definitely the first choice.
I was planning to rewrite the vbb url to further improve it, write it as a VBB plug-in, and add the background switch function (setting), but the school started, I was a senior, I want to spend another time on zhuqiao. I am very busy, and the network cable will expire in a few days. I don't want to renew it. I want to rent a house and close it for half a year. So I won't write it.

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.