This pack is for converting any AutoTheme theme to using ShortURLs.
This pack includes a Short URL rewriting function for making your site more
search-engine and human-friendly. To make your Postnuke site search-engine
friendly, the URLs have to be simplified and shortened with no long query
strings appended. The included function scans the output of Postnuke and renders
a much simpler URL that looks like a regular static HTML page to the search
engines, and are also much easier for us humans to digest, convenient for
posting in forums.
So instead of having
modules.php?op=modload&name=News&file=article&sid=6&mode=thread&order=0&thold=0
you may have
Article6.phtml
or instead of
modules.php?op=modload&name=Search&file=index&action=search&overview=1&active_stories=1&stories_author=msandersen
You have
Search-msandersen-1-1-.phtml
The server, however, must be able to understand these short URLs and translate them into their proper long form.
To enable short URLs, first of all you must be hosted on an Apache server with the URL rewrite module (mod_rewrite) enabled (possibly an IIS server with a commercial rewrite plugin). Many Linux servers do by default, such as Red Hat Linux. You may have to ask you host provider for details, and if they will enable it if it isn't.
Note: As mentioned above, it should be possible to use it
on a Microsoft IIS server with modules like QwerkSoft's
IIS Rewrite
(www.qwerksoft.com/products/iisrewrite/),
a commercial stripped-down version of Apache's mod_rewrite,
or with a little modification, ISAPI_Rewrite
(www.isapirewrite.com/), a shareware URL
rewriter. I have no access to these, however, so cannot verify it.
To test what server you are hosted on, you may also upload the provided phpinfo.php file to your site and access it. It will spew out a long detailed list of your PHP setup, including what server you are hosted on.
Go to 'Find' in you browser, usually under 'Edit', and enter 'SERVER_SOFTWARE'.
It must be an Apache server.
It can't tell you if mod_rewrite is enabled, although if it's a UNIX/Linux server,
you can tell if it has been compiled with the module. See below on how to test
if it's enabled and working.
If you're hosted, you only need worry about the .htaccess file being placed in the site root as far as URL rewriting is concerned, as well as replacing the theme.php file in whatever theme you're fixing, and placing the functions.php file alongside it. See next section.
You may want to have your site set to a different theme as a general precaution when testing new themes.
Edit the main configuration file, httpd.conf, in a text editor (not word processor), and search for rewrite_module.
If you use Apache 1.3, make sure these two lines are uncommented (no hash # in front)
LoadModule rewrite_module modules/mod_rewrite.so
and a little further down,
AddModule mod_rewrite.c
Apache2 only has the first line.
The path must point to the server's modules directory, and the file mod_rewrite.so must be in there. Once you restart the server, mod_rewrite should be enabled.
It is recommended for performance that once you have confirmed the rewrite rules work in the .htaccess file in the next section, you move them into httpd.conf, as by necessity processing of .htaccess files comes a long way down the line, after all URLs have been converted to absolute file paths on the server. So to process the rewrite rules, the paths have to be retranslated into URLs, a relatively slow process.
Copy the .htaccess file to the Apache configuration
directory and rename it something like ShortURL.conf,
for instance /etc/apache/conf/ShortURL.conf
or whatever your Apache config directory is.
In an appropriate place in httpd.conf (not nested within another Directory directive), add:
<Directory "C:/Apache/htdocs/nuke"> Options Indexes FollowSymLinks Includes AllowOverride All order allow,deny allow from all RewriteEngine On RewriteRule ^$ index.php Include conf/ShortURLs.conf </Directory>
substituting the path to your Postnuke site, eg
<Directory "/var/www/vhosts/mysite/htdocs">
The sample RewriteRule above simply rewrites www.sitename.com/ to www.sitename.com/index.php. It is optional, but if you desire another default page for the PostNuke site root, you can set it here.
Please note if you have set the RewriteEngine On directive in the main httpd.conf file, you should comment it out or remove it in the new ShortURL.conf file, as well as ensuring the RewriteOptions directive isn't set:
# RewriteEngine On # RewriteOptions 'inherit'
If you're using Virtual hosts, you can set the directive
RewriteOptions 'inherit'
at the top of the virtual host section to inherit rules put in the main part of httpd.conf. Putting this directive in the main section will cause a server error, as there's nowhere to inherit from.
To test the new theme, don't change site preferences just yet.
While using another theme, go to www.yoursite.com/index.php?theme=Newtheme
by entering it in the URL bar, where newtheme is
the modified theme, paying attention to correct case of the name. Unix servers
are very particular, and using a lowercase letter where uppercase is required
will get you an error.
Once the new theme is displayed, hover over some links and see if they've been converted to ShortURLs. That means the functions.php rewrite file is working. Try clicking on a link and see if you are redirected to the correct page. Click the browser Back button if you like and try a few others to see all is well. If it is, feel free to go to the Admin section of your site and change to the theme.
If the links are converted, but clicking them gets an error, referring to the ShortURL and not the full URL, then the URL rewriting module isn't enabled for your site. The server must be set to allow per-directory overrides (allowing users to set .htaccess files), and the file must be readable by the server. As above, contact your host and ask if they have an Apache server with the mod_rewrite module installed, and if it can be enabled for you.
It should be noted that for 'new-style' modules, whereas links in sideblocks should work, their output to the center column can't be captured for processing at this stage due to the way it's implemented.
(X being a number, square brackets represent a value)
| [modulename].phtml | old-style modules, eg News.phtml |
| [module]-main.phtml | new-style modules like Postcalendar-main.phtml |
| ArticleXX.phtml | where XX is the story ID |
| ArticleXX-[mode]-orderX-thresholdX.phtml | |
| TopicXX[all].phtml | where XX is the topid ID, 'all' for all topics listing. |
| CategoryXX.phtml | |
| Sections-articleXX.phtml | |
| FAQ-CategoryX-[Category]-ParentX-myfaq-[yes].phtml | |
| Search-[ArticleAuthor]-[overview]-[ActiveStories]-[TopicID].phtml |
|
| SendArticleXX.html |
|
| PrintArticleXX.html | |
| PostCalendar-[day]-[month]-[year].phtml | For the postCalendar module, where the date is the day you want to enter an event for. |
| PostCalendar-AddEvent-[day]-[month]-[year].phtml | PostCalendar events |
| PNphpBB2-[type]-(t [topidID] or f [forumID] or c [categoryID]).phtml | For PNphpBB2 v1.1 and up (not <=v1.0) |
For AutoTheme news, downloads and help forums, go to Spidean's site:
For AutoTheme ShortURL help forums and AT theme downloads check out Alan Sparke's site:
http://postnuke.alansparkes.net
-----------=======~~~~oOo~~~~=======-----------
A copy of this document can be found here.
Original AutoTheme ShortURL hack by Richard Wing and MagicX
Adapted by Alan Sparkes May 2003
Adapted by Thor (Martin Stær
Andersen) June 2003
Based on the work of Karateka
and ColdRolledSteel
http://www.mtrad.com/SimpleURL.php
See also:
http://forums.postnuke.com/index.php?name=PNphpBB2&file=viewtopic&t=10769&start=0
for instructions on converting regular PostNuke 0.7x themes.
Martin Stær Andersen
Last updated 2003/10/25