PostNuke

Flexible Content Management System

News

Search Engine friendly URLs with $PATH_INFO and without Apache mod_rewrite

Contributed by on Apr 27, 2002 - 08:32 AM

As most of us I run my website at cheap webspace and can not activate the Apache module mod_rewrite, because my provider does not allow so.




I wrote this article to prove, that $path_info can be used to add search engine friendly URLs to PostNuke without the need of advandced Apache modules.




Now the way PostNuke generates its URLs needs to be changed to make it work. I spend some hours on this, but could not manage it to work.


So any help is apperciated. Post your code (or link to your code) as a follow up.




To demonstrate what i mean i made a test link looking like this:


http://www.jan-mantkowski.de/modules.php/op/modload/name/News/file/article/sid/7/mode/thread/order/0/thold/0




Click here to give it a try.




You can also read this article at my website at http://www.jan-mantkowski.de.




This kind of links will be followed by seachengines, and do work within PostNuke environment.


I only did two modifications to modules.php and header.php. The files for version 0.713 can be downloaded here.




Lets have a look at what i changed:


modules.php


Add right after the credits:




if(isset($PATH_INFO)) {


$vardata = explode('/', $PATH_INFO);


$num_param = count($vardata);





if($num_param % 2 == 0) {


$vardata[] = '';


$num_param++;


}





for($i = 1; $i < $num_param; $i=$i+2) {


$$vardata[$i] = $vardata[$i+1];


}


}




The code will extract the variables and the values from the $path_info and make them available for PostNuke.


For in deph informations have a look at this article at www.zend.com.




header.php


At aprox. line 155 you will find:


global $themesarein;




Change the following line:


echo "\n";


to


echo "\n";


and


echo ";@import url(\"".$themesarein."themes/".pnUserGetTheme()."/style/style.css\"); ";


to


echo ";@import url(\""."http://www.yourside.com/"."themes/".pnUserGetTheme()."/style/style.css\"); ";




This is to fix the path for the style sheets. By unknown reason without this changes PostNuke will not find the stylesheets anymore.




You are ready now.




To test it you can create an new article with a link pointing to an other article.


Replace all = and ? with /


You will notice that the link is clickable and works.




So now we need to change the way PostNuke generates its URLs to make sure we will be listed by searchengines.






Pardon my english, i am german.




Jan
4350