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:
- function print_output($vartext, $sendheader = true)
- {
- global $pagestarttime, $querytime, $vbulletin;
- global $vbphrase, $stylevar;
-
- if ($vbulletin->options['addtemplatename'])
- {
----------------------------------------------------------
Changed:
---------------------------------------------------------
PHP code:
- //###################################### ###
- // Add two functions to start
- Function rewrite_forum ($ extra1, $ sid, $ fid, $ order, $ page = 0, $ extra2 = '')
- {
- Return '<A'. stripslashes ($ extra1). 'href = "F-'. ($ Sid? Substr ($ Sid, 0, 32): 0). '-'. $ FID. '-'. ($ order? $ Order: 0). '-'. ($ page? $ Page: 1). '.html "'. stripslashes ($ extra2).'> ';
- }
- Function rewrite_thread ($ extra1, $ Sid, $ tid, $ page = 0, $ extra2 = '')
- {
- Return '<A'. stripslashes ($ extra1). 'href = "T-'. ($ Sid? Substr ($ Sid, 0, 32): 0). '-'. $ tid. '-'. ($ page? $ Page: 1). '.html "'. stripslashes ($ extra2).'> ';
- }
- // Add two functions to end
- //###################################### ###
- Function print_output ($ vartext, $ sendheader = true)
- {
- Global $ pagestarttime, $ querytime, $ vbulletin;
- Global $ vbphrase, $ stylevar;
- //###################################### ###
- // Add a program to start
- $ Searcharray [] = "/\ <a (. *) href \ = \" forumdisplay \. php \? (S \ = (.*))? F \ = (\ d +) (& amp; order \ = (asc | desc ))? (& Amp; page \ = (\ d + ))? \ "([^ \>] *) \>/E ";
- $ Replacearray [] = "rewrite_forum ('\ 1',' \ 3', '\ 4',' \ 6', '\ 8 ', '\ 9 ')";
-
- $ Searcharray [] = "/\ <a (. *) href \ = \" showthread \. php \? (S \ = (.*))? T \ = (\ d +) (& amp; page \ = (\ d + ))? \ "([^ \>] *) \>/E ";
- $ Replacearray [] = "rewrite_thread ('\ 1',' \ 3', '\ 4',' \ 6', '\ 7 ')";
- $ Vartext = preg_replace ($ searcharray, $ replacearray, $ vartext );
- // Add the program to end
- //###################################### ###
- If ($ vbulletin-> options ['addtemplatename'])
- {
-------------------------------------------------
If you want to rewrite archive at the same time, make the following changes:
------------------------------------------------
Find the following statement in archive/index. php:
--------------------------------------------
PHP code:
- if (SLASH_METHOD AND strpos($archive_info , '/archive/index.php/') === false)
- {
- exec_header_redirect($vbulletin->options['bburl'] . '/archive/index.php/');
- }
-----------------------------
Change
----------------------------------------------------------
PHP code:
- if (SLASH_METHOD AND strpos($archive_info , '/archive/') === false)
- {
- exec_header_redirect($vbulletin->options['bburl'] . '/archive/');
- }
------------------------- Step 2 ---------------------------
-----------------------------------------------------
Add the file ". htaccess" to the root directory of the forum, which contains the following content:
-----------------------------------------------------
Code:
- RewriteEngine On
- # Modify "/vbb" to your forum directory address. If the program is placed in the root directory, change "/vbb" "/"
- RewriteBase/vbb
- RewriteRule ^ f-([0-9a-z] +)-([0-9] +)-(0 | asc | desc)-([0-9] + )\. html $ forumdisplay. php? S = $1 & f = $2 & order = $3 & page = $4
- RewriteRule ^ t-([0-9a-z] +)-([0-9] +)-([0-9] +) \. html $ showthread. php? S = $1 & t = $2 & page = $3
- 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:
- RewriteEngine On
- # Modify "/vbb" to your forum directory address. If the program is placed in the root directory, change "/vbb" to "/archive"
- RewriteBase/vbb/archive
- 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.