TipiWiki2

[ ShortUrls ]

Recent Changes | Find Page | Front Page |

This manual is in it`s early beginning and many pages do not have content yet.
If you would like to participate in editing the manual, register or login at Canvas and follow the "PagEd Wiki Project" link. You will then see an "Edit" link on every page.

**NOTE: THIS DOES NOT WORK WITH PAGED0.930 AND UP!!!!
Note: This manual is written for PostNuke, I do not know if it works with any other CMS.

I noticed that pages do not get indexed by Google or Yahoo (or any other search engines) at all. Only the frontpage. This annoys me a lot. As you have pages with valuable information, it is not found by anybody (unless they know your domain).

To check how well your site is indexed by Google, type in google:

site:yourdomain.com -ajdhasdjh.

Google now shows all the pages in its database within yourdomain.com without the word -ajdhasdjh. In my case it just showed one page: index.php. Not really a satisfying result as there are around a 100 pages on the site (at this moment).

Now it was time to see if it would work with Short or Simple URL's. I searched the web, and found different solutions to make it work. Then I hacked my theme to make it work with short/simple URL's. I tried to find a "one-fits-all" solution, and combined different approaches into this set of files.

The first thing that is important is to see if the rewrite-engine is functioning on you webserver. To do this install the .htaccess file in your root folder and type in your webbrowser http://www.yourdomain.com/paged-XX.html (XX is a number that corresponds to a PagEd_id=XX)

Note:
Some FTP clients hide .htaccess files from server view. Upload the included htaccess file, then after upload, do a rename to add the extra dot before htacesss, so that the file is called .htaccess. Now it may disappear, but it is there, only invisible.

[some extra info on .htaccess]
In the .htaccess file there is a first line that turns off session id's in postnuke. This is important, as otherwise the page will look like http://www.yourdomain.com/paged-XX.html?POSTNUKESID=3cc3b9326fa693f39766ee36dc2636d9 and Google will still not index the pages, as it thinks it is dynamic content. -> I have not yet been able to verify this myself, as I discovered this when I was writing this document ;-)

The .htaccess file also works with most other modules in postnuke.

If this works, your ready to go and hack your theme.

For this you need an extra file called functions.php. This file is included in this pack. Open it in your favourite text editor and search for: $base_url = "http://www.yourdomain.com/"; Replace yourdomain.com with the address of your site, then upload functions.php in your themes/YourTheme folder where your theme.php is.

Now open your theme.php in your favourite text-editor.

Add the following lines to your theme.php (dont forget to backup your theme.php as this might not work, and you will need it then)

1. At the beginning of your theme add:

global $simple_urls, $simple_uri;

if there already is a global add $simple_urls, $simple_uri to it, make sure the line ends with an ; and that there is a , in between variables

2. Immediately under "global" add this line

$simple_urls = true; // enable/disable simple URL functionality. true or false

3. Immediately under "themes_get_language();" add:

$uri=basename($_SERVER['PHP_SELF']); // Note: For PHP earlier than 4.1.0, use $HTTP_SERVER_VARS instead
if ($uri == "user.php" | $uri == "admin.php" | defined("LOADED_AS_MODULE"))

   { $simple_uri="old"; }
else{ $simple_uri="new"; }

if ($simple_urls)
   require_once("functions.php");

4. At the beginning of "themeheader()" after the { add:

global $simple_urls, $simple_uri;

if there already is a global add $simple_urls, $simple_uri to it, make sure the line ends with an ; and that there is a , inbetween variables

5. For some themes it works fine if you add the next lines of code after the $slogan, $sitename etc. So try this first.

// Start Simple URL processing
if ($simple_urls && $simple_uri == "old")
ob_start(); // Buffering content for Simple URL processing

For some other themes this DOES NOT work. I do not know why, maybe somebody can explain it to me someday. If it does not work, search your theme for "blocks('left');"
Now insert the code before this.

6. At the end of your "themeheader()" before the last } add the next lines of code:

// SimpleURL output
 if ($simple_urls && $simple_uri=="new") {
   $obcontents = ob_get_contents();
   ob_end_clean();
   ob_start();
   if ($simple_urls)
       { echo simplify_urls($obcontents); } //display modified buffer to screen 
else{ echo $obcontents; }
 } // End Simple URL

7. At the beginning of function themefooter() after the { add:

global $simple_urls, $simple_uri;

if there already is a global add $simple_urls, $simple_uri to it, make sure the line ends with an ; and that there is a , inbetween variables

8. At the end of function themefooter() before the last } add:

if ($simple_urls) {
$obcontents = ob_get_contents(); // Get output buffer content and flush buffer
ob_end_clean();
if ($simple_uri == "new") // Extra ob_start for New module
ob_start();
echo simplify_urls($obcontents); // Display modified buffer to screen
   } // End SimpleURL

Now it should work. Upload the new theme.php and you should have short / simple URLs.