美化URI

From Linux Web Expert

Revision as of 09:45, 3 October 2023 by >LittlePaw365
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Template:Interlanguagelink: en

N/A
Describe configuration steps on how to enable prettify URIs (or "short URIs").
Table of Contents

如果希望拥有更符合互链式数据(linked data,链接资料,链接式数据)原则的,美观精致的统一资源标识符(pretty URIs),就需要对MediaWiki和SemanticMediaWiki进行一些设置。这里,将以semanticweb.org为例,介绍其工作机制。

目标

对于维基站点上的每个页面,希望其拥有正规定义的标识符:

必要的步骤

为此,需要做的事情包括:

1) 告诉LocalSettings.php使用简短的URLs

// Pretty URIs MW
$wgScriptPath = "/";            # 指向实际文件的路径
$wgArticlePath = "/wiki/$1";    # 虚拟路径。该目录必须有别于$wgScriptPath之中所使用的目录
$wgUsePathInfo = true;          # 启用pretty URLs

//SMW命名空间配置
$smwgNamespace = 'http://semanticweb.org/id/';

2) 定义别名,并重新编写Apache网络服务器当中的规则(httpd.conf

# 定义别名 
Alias /wiki C:/webserver/htdocs/LinkedDataSMW/index.php

# 重新编写至SMW的URIResolver
RewriteRule ^/id/(.*) /wiki/Special:URIResolver/$1 [L,P]

→ 关于MW的专门信息以及替代手段,请参见这里

#scite could not render a citation text for reference "gh:smwo:26:307161649" because type "issuecomment" was not assigned to a template.
#scite could not render a citation text for reference "gh:smwo:26:307169823" because type "issuecomment" was not assigned to a template.