PHPNuke 7.5 - Googlifier mod
A brief tutorial on mod_rewrite and how to get Googlifier installed on PHPNuke v7.5
I have mentioned before that Google wasn't indexing the forum pages of the site although it seemed reasonably happy with most of the rest of the site. It is well known that search engine spiders such as Googlebot and the Yahoo 'Inktomi Slurp' aren't keen on dynamically created websites that use navigation URLs such as
www. deepblue.uk.net/modules.php?name=Content&pa=showpage&pid=13&sid=ahi39ry39f8ug32fio78
This URL is requesting that the page called modules.php residing in the root directory of the site is loaded and it is sending the additional information to the page for processing: Name is Content, pa is showpage, and pid is 13 and sid (session id) is 13&sid=ahi39ry39f8ug32fio78. The topic of making websites more interesting to search engines is known as Search Engine Optimisation or SEO for short and is covered in another thread on the forum. Please note that details about the session ID and how to remove it are also given in another thread on the forum.
They much prefer simple URLs such as
www. deepblue.uk.net/squash_ladder_info.htmlThere are a number of ways to solve this using addon mods for phpnuke (or writing your own) in combination with an Apache Sever module called mod_rewite. All methods follow a similar process comprising two stages. The examples given here are loosely based on Googlifier which is explained in a later posting.
First the website needs to generate the desired link URL as normal but then change it to a shortened format preferably ending in '.html'. The search engine spider when it reaches the page will then see non-dynamic URLs and is more likely to index them. If we take the PHPNuke URL
www. deepblue.uk.net/modules.php?name=Forums&file=viewtopic&t=33&start=0we need PHPNuke to convert this to a format where all the information is included within the page name and we don't want any details being sent after the file extension part e.g. '.html' or '.php'. Details after the extension start with an '?' sign and take the format data name=[value]. Numerous additional data values can be passed in the name=[value] format by separating them by '&'s. What the mods like Googlifier do is take the page output and use a regular expression replace function to strip out in a logical and structured way, all the data after the '?'. In this example, we can tell that we wish to view in the forums the topic number 33 and we are also parsing the start value of 0.
The replacement of the URL occurs in the header.php and footer.php file of the nuke site. There is an array that contains the dynamic php URL structures and an array that contains the static html output structure. The function preg_replace is then used to swap out the contents of the page before it is sent to the browser.
For the above example the input regular expression is:
(?<!/)modules.php\?name=Forums&file=viewtopic&t=([0-9]*)&start=([0-9]*)
and the output expression is:
"forumtopic\\1-\\2.html"
The double backslashes followed by numbersrs are back references to replace the first matched pattern value [0-9]* (any number from 0 to infinity) in the replaced URL. So, we swap the 'name=Forums&file=viewtopic&t=' part for 'fortopic' and replace the first backreference with the value '33' followed by a hyphen and then the second backreferenced value '0' and we add '.html' to the end. So our finished search engine friendly URL ends up as:
www. deepblue.uk.net/fortopic33-0.html
That's all well and good but how is our web site going to function now as there is no such page as forumtopic33-1.html on our site??!?
The second part of the process is therefore for the web server to translate this altered URL back to a URL that the dynamic website understands. This is where the modrewrite comes in. It uses a regular expression to replace the contents of the altered URL with the dynamic structure that PHPNuke understands. Once installed on your Apache webserver you need to put the rewrite rules into the .htaccess file for each directory that is affected by your command. For this example the .htaccess file resides in the root directory. It needs to be switched on first using 'RewriteEngine On' and then the rules take a similar structure using regular expression pattern matching again. For this example the rule would be:
RewriteEngine On RewriteRule ^forumtopic([0-9]*)-([0-9]*).* modules.php?name=Forums&file=viewtopic&t=$1&start=$2
This finds the word 'fortopic' followed by a number followed by a hyphen then another number. It takes the number values as backreferences and swaps the short form URL back to the original URL structure:
www. deepblue.uk.net/modules.php?name=Forums&file=viewtopic&t=33&start=0
Note that we have removed the sid value in a separate process described elsewhere.
So that's it really. Quite simple in many respects but quite complex in others. The details of getting thie Googlifier mod installed on PHPNuke 7.5 will appear shortly along with further reading.
The good news is that the above changes have been effective so far and that Google is starting to index the forum pages :P
Hi
How much if I need your mod_rewrite service for my site
http://www.touchds.com ?
I don't have a large budget for this, this is just a small site and please quoate me an reasonable price if you are interested and willing to help
my email protonship at yahoo . com
Thanks
Hi,
I don't really have time to work on other sites I'm afraid but mod rewriting a site isn't hard if you are using a standard CMS like PHPNuke or your board is PHPBB.
Let me know what CMS and forum software you are using and I might be able to point you in the right direction. If it's regarding how to actually set up the mod_rewrite then I will expand the tutorial to explain it more clearly.
Matt

When looking for a nuke mod to rewrite URLs you have a few choices available. Perhaps best known are Googletap, GoogleTap Next Gen and Googlifier. It should be pointed out that even though these all bear the name google they are equally as effective for all spidering search engines. I wanted something that was quite straight forwards so I could play around with the coding to customise where desiired. I therefore went for Googlifier which has a support forum here.
As mentioned above it is necessary to make some modifications to the .thaccess, header.php and footer.php files in the root nuke directory. The installation package comes with samples of these files for different nuke installations so you first need to backup your originals and then copy the new files to the correct locations and upload to the web server. If you have already got modifications to these files yourself you will need to manually alter the files. I have a dynamic page titles mod in header.php so only needed to add that back in. I also had a few lines in my .htaccess which needed to be added back too.
Although Googlifier will convert all your site URLs to static ones I only really wanted to change the behaviour of the forum URLs at this stage. Furthermore I only wanted to change the URLs that pointed to topics and posts (and the forums indexes and navigation too). I didn't want to change the behaviour of admin functions and post and reply buttons as I don't want a search engine going to those links.
I therefore removed most of the entries and modified some of the existing header.php and .htaccess entries as follows:
header.php (please be aware this contains some word wrapped lines to fit the page
function replace_for_mod_rewrite(&$s) { $urlin = array( "'(?<!/)modules.php\?name=Forums&file=viewforum&f=([0-9]*)&unwatch=forum&start=([0-9]*)'", "'(?<!/)modules.php\?name=Forums&file=viewforum&f=([0-9]*)&watch=forum&start=([0-9]*)'", "'(?<!/)modules.php\?name=Forums&file=viewforum&f=([0-9]*)&topicdays=([0-9]*)&start=([0-9]*)'", "'(?<!/)modules.php\?name=Forums&file=viewforum&f=([0-9]*)&mark=topics'", "'(?<!/)modules.php\?name=Forums&file=viewforum&f=([0-9]*)'", "'(?<!/)modules.php\?name=Forums&file=viewforum&f=([0-9]*)'", "'(?<!/)modules.php\?name=Forums&file=viewtopic&t=([0-9]*)&view=previous'", "'(?<!/)modules.php\?name=Forums&file=viewtopic&t=([0-9]*)&view=next'", "'(?<!/)modules.php\?name=Forums&file=viewtopic&t=([0-9]*)&postdays=([0-9]*)&postorder= ([a-zA-Z]*)&start=([0-9]*)'", "'(?<!/)modules.php\?name=Forums&file=viewtopic&t=([0-9]*)&start=([0-9]*)&postdays=([0-9]*)& postorder=([a-zA-Z]*)&highlight=([a-zA-Z0-9]*)'", "'(?<!/)modules.php\?name=Forums&file=viewtopic&t=([0-9]*)&start=([0-9]*)'", "'(?<!/)modules.php\?name=Forums&file=viewtopic&t=([0-9]*)&watch=topic&start=([0-9]*)'", "'(?<!/)modules.php\?name=Forums&file=viewtopic&t=([0-9]*)&unwatch=topic&start=([0-9]*)'", "'(?<!/)modules.php\?name=Forums&file=viewtopic&t=([0-9]*)&highlight=([a-zA-Z0-9]*)'", "'(?<!/)modules.php\?name=Forums&file=viewtopic&t=([0-9]*)'", "'(?<!/)modules.php\?name=Forums&file=viewtopic&p=([0-9]*)&highlight=([a-zA-Z0-9]*)'", "'(?<!/)modules.php\?name=Forums&file=viewtopic&p=([0-9]*)'", "'(?<!/)modules.php\?name=Forums&file=viewtopic&p=([0-9]*)'", "'(?<!/)modules.php\?name=Forums&file=index&c=([0-9]*)'", "'(?<!/)modules.php\?name=Forums&file=index&mark=forums'", "'(?<!/)modules.php\?name=Forums&file=index'", "'(?<!/)modules.php\?name=Forums&file=index'", ); $urlout = array( "unwatchforum\\1-\\2.html", "watchforum\\1-\\2.html", "viewforum\\1-\\2-\\3.html", "forum\\1.html", "forum\\1.html", "forum\\1.html", "pretopic\\1.html", "nextopic\\1.html", "fortopic\\1-\\2-\\3-\\4.html", "fortopic\\1.html", "fortopic\\1-\\2.html", "watchtopic\\1-\\2.html", "unwatchtopic\\1-\\2.html", "fortopic\\1.html", "fortopic\\1.html", "post\\1.html", "post\\1.html", "post\\1.html", "forcat\\1.html", "forums.html", "forums.html", "forums.html", ); $s = preg_replace($urlin, $urlout, $s); return $s; }and in .htaccess again this unfortunately contains word wrapped lines
References / Further Reading
Chris Karakas's PHP-Nuke: Management and Programming