Tutorial: How to setup and use smartURL
The smartURL feature allows the use of freely defineable URLs that can be edited with the backend system.
To use the smartURL feature, the following is required:
- mod_rewrite enabled in apache
- Apache configured to allow the mod_rewrite statements in .htaccess (Directive AllowOverride)
Usually, the installer sets up the smartURL feature if it detects that you have mod_rewrite installed in Apache. Therefor it copies and modifies the file htaccess_smartURL_sample from phenotypeRoot to your docroot.
If your system does not meet the requirements for smartURLs, Phenotype works with the old-style idURLs (index.php?id=3).
To enable smartURL by hand:
- set
define (“PT_URL_STYLE”, “smartURL”);in _config.inc.php - ensure mod_rewrite is enabled in your Apache
- ensure you are allowed to set Rewrite Directives in an htaccess file in your phenotype docroot (the htdocs subfolder of phenotypeRoot)
- copy the htaccess_smartURL_sample from phenotypeRoot to your docroot. filename must match the htaccessFilename of your apache (usually .htaccess)
- edit the copied file, modify the line with
RewriteBase /phenotype-svn/trunk/htdocs/to fit your SERVERURL (what you enter in your browser after the hostname to get to your docroot.
Usage
To use smartURLs with a page in Phenotype < 2.6 you have to set an URL in the configuration tab of the page. This URL is then used as the page URL.
Since Phenotype 2.6, smartURL is enhanced. There are several possible modes to use the page title or combinations of the page title and the path of the page in the page tree automatically as smartURLs.
Hints
Url-Encoding of parameters
The smartURL functionality relies on mod_rewrite from Apache. Currently, in all stable versions of Apache’s mod_rewrite (2.0 and 2.2) is a bug in handling URLs with special characters like space, + that have to be encoded in URLs. For me it looks like the url is decoded from mod_rewrite, but is not re-encoded again for the rewritten request. See https://issues.apache.org/bugzilla/show_bug.cgi?id=34602 for more info.
There are 2 solutions to work around this bug in Phenotype:
- Don´t use those characters in URLs. For the page names, these characters will be automatically eliminated or replaced by safe ones
- If you need encoded characters in smartURLs, encode them twice like urlencode(urlencode($s)). But be warned, that this only works as long as Apache has this bug. If you upgrade to a future version of Apache without this bug, your applications behaviour will change. You have been told..

You think Phenotype Wiki/Documentation could be better?
We too. Please contribute: Edit this page
Recent Blog Posts
- Finally Multibyte - Phenotype 3.0
- Phenotype 2.9 explained
- Integration of PHPIDS (PHP-Intrusion Detection System)
- New Release: Phenotype 2.8 Ready for Download
- Restart: New Phenotype Website Live
- Phenotype worth: 2 Million $
- New Feature: Automatic Image Version Creation
- Additional smartURL variable: smartPATH