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 semanticweb.org.

Aim

Usually, SMW automatically creates the respective URIs for all resources described, e.g., see Karlsruhe in semantic-mediawiki.org:

However, you may want to have pretty URIs, e.g., see Karlsruhe in semanticweb.org:

Necessary Steps

For that, one needs to do:

1) Add configuration for short URLs 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

// Namespace config for Semantic MediaWiki
$smwgNamespace = 'https://www.semantic-mediawiki.org/id/';

2) Define alias and rewrite rules in the VirtualHost on the Apache webserver

# Define Alias 
Alias /wiki /var/www/htdocs/w/index.php

# Rewrite to URIResolver of Semantic MediaWiki
RewriteRule ^/id/(.*) /wiki/Special:URIResolver/$1 [L,P]

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