Help:Pretty URIs

From semantic-mediawiki.org
Jump to: navigation, search
SMW admin manual
Installation
Configuration
Concept caching
Fixed properties
Using SPARQL and RDF stores
SPARQLStore
Pretty URIs
Troubleshooting
Repairing SMW's data
Extensions
Basic extensions
Semantic extensions
SMW user manual
Table of Contents

If one wants to have pretty URIs (or "short URIs"), more compliant to linked data principles, some settings for MediaWiki and SemanticMediaWiki are necessary. Here is how it works, exemplified for <www.semantic-mediawiki.org>.

Important noteImportant Note:
It is recommended to do this setting either immediately on the initial setup of the wiki and to not change this at a later stage since the URI from configuration parameter $smwgNamespaceSets the namespace of exported URIs is used as an identifier that should not change. A change would turn the respective URI into a different entity which in fact it is not.1

Situation

Usually, Semantic MediaWiki automatically creates the respective URIs for all resources described, e.g. see Karlsruhe in <sandbox.semantic-mediawiki.org>:

Aim

However, you may want to have pretty URIs, e.g., see Karlsruhe in <www.semantic-mediawiki.org>:

The expected behaviour is that the RDF version forwards to the resource ID which in turn redirects to the HTML version.2

Necessary steps

For that, using <www.semantic-mediawiki.org> as an example, one needs to do:

1) Add configuration for short URLs and for the semantic namespace to your "LocalSettings.php" file:

// Pretty URIs MediaWiki
$wgScriptPath = "/";            # Path to the actual files.
$wgArticlePath = "/wiki/$1";    # Virtual path. This directory MUST be different from the one used in $wgScriptPath
$wgUsePathInfo = true;          # Enable use of pretty URLs (may not be required depending on server setup)

// Namespace configuration for Semantic MediaWiki after the enableSemantics call
$smwgNamespace = 'https://www.semantic-mediawiki.org/id/';

2) Define alias and rewrite rules in the VirtualHost (".conf" file) on the Apache webserver

# Rewrite to URIResolver of Semantic MediaWiki
RewriteRule ^/id/(.*) https://www.semantic-mediawiki.org/wiki/Special:URIResolver/$1 [L]

See also


This documentation page applies to all SMW versions from 1.5.0 to the most current version.
      Other languages: dezh-hans

Help:Pretty URIs en 1.5.0