Nick
07-13-2009, 04:43 PM
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=profileFriendly 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.
Passing parameters
If a 'page' is not given, Hotaru will default to 'index'. With friendly urls turned off, you can just pass parameters by adding 'key' => 'value' pairs to the url() function, but here are some htaccess rules to consider when friendly urls are turned on.
RewriteCond %{REQUEST_URI} !\.(css|php|png|jpg|gif|ico|js|inc|txt)$
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.
Examples
Friendly URLs OFF:
myhotarusite.com/index.php?page=34
myhotarusite.com/index.php?page=profileFriendly 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.
Passing parameters
If a 'page' is not given, Hotaru will default to 'index'. With friendly urls turned off, you can just pass parameters by adding 'key' => 'value' pairs to the url() function, but here are some htaccess rules to consider when friendly urls are turned on.
RewriteCond %{REQUEST_URI} !\.(css|php|png|jpg|gif|ico|js|inc|txt)$
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.