Hotaru Docs

 [həʊdɒks]

Making Friendly URLs

Hotaru offers a friendly url method which you can turn on or off by setting it to true or false in Admin->Settings.

Examples

Friendly URLs OFF:

myhotarusite.com/index.php?page=34
myhotarusite.com/index.php?page=profile

Friendly URLs ON:

myhotarusite.com/name-of-the-post/
myhotarusite.com/profile/

Of course, as a plugin developer, you don't know whether the user has turned friendly URLs on or off, so you should use Hotaru's url() function instead of hard-coding the links:

echo "<a href='" . $h->url(array('page'=>'page_wanted')) . "'>Page Wanted</a>

You can use this one for Admin pages:

echo "<a href='" . $h->url(array('page'=>'page_wanted'), 'admin') . "'>Page Wanted</a>

Note that the rewrite rules for Admin in the htaccess file are quite limited, so to avoid problems (e.g. with pagination), it's safer to link directly with /admin_index.php?page=page_name.

Sending more than one parameter

If a 'page' is not given, Hotaru will default to 'index'.

You can pass additional parameters by adding 'key' => 'value' pairs to the url() function. E.g.:

echo "<a href='" . $h->url(array('page'=>'profile', 'user'=>'spaceman')) . "'>Spaceman's Profile</a>

For advanced users, here are some htaccess rules to consider when friendly urls are turned on.

RewriteRule \.(css|php|png|jpg|gif|ico|js|inc|txt|gz|xml|html)$ - [L]
RewriteRule ^([^/]*)/?$ index.php?page=$1 [L]
RewriteRule ^([^/]*)/([^/]*)/?$ index.php?$1=$2 [L]
RewriteRule ^([^/]*)/([^/]*)/([^/]*)/?$ index.php?page=$1&$2=$3 [L]
RewriteRule ^([^/]*)/([^/]*)/([^/]*)/([^/]*)/?$ index.php?$1=$2&$3=$4 [L]
RewriteRule ^([^/]*)/([^/]*)/([^/]*)/([^/]*)/([^/]*)/?$ index.php?page=$1&$2=$3&$4=$5 [L]
RewriteRule ^([^/]*)/([^/]*)/([^/]*)/([^/]*)/([^/]*)/([^/]*)/?$ index.php?$1=$2&$3=$4&$5=$6 [L]

For urls with an odd number of parameters, the first is always the page name. The rest, and also those in urls with an even number of parameters, are 'key' => 'value' pairs. While not incredibly flexible, it does allow for plugin developers to use friendly urls without needing the end user to modify the htaccess file.

Getting StartedDesign and LayoutPlugin DevelopmentAdvanced TopicsFunction ReferenceTroubleshooting