. "%META:TOPICPARENT{name=\"VirtTipsAndTricksGuide\"}%\n\n---+Simple Linked Data Deployment using Virtuoso's HTTP Re-write Rules\n\n---++What?\nUse basic URL pattern as the basis for re-write rules that serve 5-Star Linked Data from a Virtuoso instance.\n\n---++Why?\nLinked Data offers a powerful mechanism for incorporating the connectivity of hyperlinks (typically HTTP URIs) into the process of actual structured data representation and data access. \n\n---++How?\n\nPerquisites:\n\nThe following example demonstrates the usage of a basic URL pattern as the basis for URL re-write rules.\n\nEnsure Virtuoso's native faceted browser is installed so that you can leverage its entity description service via URL pattern: http://{hostname}/describe/?uri={URI}, for powerful HTML based follow-your-nose style of data exploration.\n\nURL Pattern: http://{hostname}:8890/id/... \nNegotiated Data Representation formats to be handled by these rules: \n\n 1 text/html via \"/page/\" path component of the URL.. \n 1 RDF (text/turtle, application/rdf+xml) via \"/data/\" path component of the URL .\n\n\n-- Goals\n-- Use slash terminated HTTP scheme URIs as Object Identifiers (Names) for Data Objects that resolve to Object Representations via a variety of URL patterns aligned to different data representation formats\n-- Object IDs take the form /id while Object Representation Addresses take the form: /data .\n--\n-- Steps\n-- Create URL re-write rules:\n-- rules for HTML based Linked Data graphs\n\nDB.DBA.URLREWRITE_CREATE_RULELIST ( 'http_rule_list_1', 1, vector ('http_rule_1', 'http_rule_2'));\nDB.DBA.URLREWRITE_CREATE_REGEX_RULE ( 'http_rule_2', 1, '/id/(.*)\\x24', vector ('par_1'), 1, '/page/%s', vector ('par_1'), NULL, NULL, 2, 303, '' );\n\n-- rules for other Linked Data Graph formats e.g. rdf/xml, n3\n\nDB.DBA.URLREWRITE_CREATE_REGEX_RULE ( 'http_rule_1', 1, '/id/(.*)\\x24', vector ('par_1'), 1, '/data/%s', vector ('par_1'), NULL, 'text/n3|application/rdf\\\\+xml|text/rdf\\\\+n3', 2, 303, '' );\n\n-- rules for Virtuoso Faceted Linked Data Navigation Service\n\n-- rule: unconditionally we redirect \"/page\" URLs internally to \"/describe\" which is the default endpoint for the Faceted Navigation Service\n\nDB.DBA.URLREWRITE_CREATE_RULELIST ( 'http_rule_list_2', 1, vector ('http_rule_3')); \nDB.DBA.URLREWRITE_CREATE_REGEX_RULE ( 'http_rule_3', 1, '/page/(.*)\\x24', vector ('par_1'), 1, '/fct/rdfdesc/description.vsp?g=http://localhost:8990/id/%s', vector ('par_1'), NULL, NULL, 2, 0, '' );\n\n\n-- \"/SPARQL\" URL pattern handling rules that allow use of SPARQL DESCRIBE queries for generating and returning Linked Data Graphs in a variety of formats determined by HTTP request URL patterns.\n\n-- query endpoints: http://localhost:8990/id/...> associated with \"/data/\" patterns\n\nDB.DBA.URLREWRITE_CREATE_RULELIST ( 'http_rule_list_3', 1, vector ('http_rule_4')); \nDB.DBA.URLREWRITE_CREATE_REGEX_RULE ( 'http_rule_4', 1, '/data/(.*)\\x24', vector ('par_1'), 1, \n'/sparql?query=describe%%20%%3Chttp%%3A%%2F%%2Flocalhost%%3A8990%%2Fid%%2F%s%%3E%%20from%%20%%3Chttp%%3A%%2F%%2Flocalhost%%3A8990%%2Fdata%%2F%%3E&format=%U', \nvector ('par_1', '*accept*'), NULL, NULL, 2, 0, '' );\n\n\n-- Virtual Directory Setup\n-- Cleanup \nDB.DBA.VHOST_REMOVE ( lhost=>'*ini*', vhost=>'*ini*', lpath=>'/id');\n\n-- Create Virtual Directory that's associated with a named URL re-write rule for handling \"/id\" URL patterns\nDB.DBA.VHOST_DEFINE ( lhost=>'*ini*', vhost=>'*ini*', lpath=>'/id', ppath=>'/id/', is_dav=>0, def_page=>'', vsp_user=>'dba', opts=>vector ('url_rewrite', 'http_rule_list_1'));\n\n-- do the same for \"/page\" URL patterns with use as Web Service endpoint for Virtuoso's Faceted Navigation Service in mind.\nDB.DBA.VHOST_REMOVE ( lhost=>'*ini*', vhost=>'*ini*', lpath=>'/page');\nDB.DBA.VHOST_DEFINE ( lhost=>'*ini*', vhost=>'*ini*', lpath=>'/page', ppath=>'/page/', is_dav=>0, def_page=>'', vsp_user=>'dba', opts=>vector ('url_rewrite', 'http_rule_list_2'));\n\n\n-- do same for \"/data\" URL patterns with other Linked Data Graph formats in mind\nDB.DBA.VHOST_REMOVE ( lhost=>'*ini*', vhost=>'*ini*', lpath=>'/data');\nDB.DBA.VHOST_DEFINE ( lhost=>'*ini*', vhost=>'*ini*', lpath=>'/data', ppath=>'/data/', is_dav=>0, def_page=>'', vsp_user=>'dba', opts=>vector ('url_rewrite', 'http_rule_list_3'));\n\n\n\n\n\n\n---+++Using CURL to verify re-write rules \n\n---++++Example 1\n\n\ncurl -L -I http://localhost:8990/id/state/MA \nHTTP/1.1 303 See Other\nServer: Virtuoso/06.02.3129 (Win32) i686-generic-win-32 VDB\nConnection: close\nContent-Type: text/html; charset=ISO-8859-1\nDate: Wed, 04 May 2011 13:44:24 GMT\nAccept-Ranges: bytes\nLocation: http://localhost:8990/page/state/MA\nContent-Length: 0\n\nHTTP/1.1 200 OK\nServer: Virtuoso/06.02.3129 (Win32) i686-generic-win-32 VDB\nConnection: Keep-Alive\nContent-Type: text/html; charset=UTF-8\nDate: Wed, 04 May 2011 13:44:24 GMT\nAccept-Ranges: bytes\nCache-Control: no-cache, must-revalidate\nPragma: no-cache\nLink: ; rel=\"alternate\"; type=\"application/rdf+xml\"; title=\"Structured Descriptor Document (RDF/XML\nhost:8990/sparql?query=define%20sql%3Adescribe-mode%20%22LOD%22%20%20DESCRIBE%20%3Chttp%3A%2F%2Flocalhost%3A8990%2Fid%2Fstate%2F\n>; rel=\"alternate\"; type=\"text/n3\"; title=\"Structured Descriptor Document (N3/Turtle format)\",; rel\nplication/rdf+json\"; title=\"Structured Descriptor Document (RDF/JSON format)\",; rel=\"alternate\"; ty\nml\"; title=\"Structured Descriptor Document (OData/Atom format)\",; rel=\"alternate\"; type=\"applicat\n=\"Structured Descriptor Document (OData/JSON format)\",; rel=\"alternate\"; type=\"text/cxml\"; title=\"Structured Des\n format)\",; rel=\"alternate\"; type=\"text/csv\"; title=\"Structured Descriptor Document (CSV format)\",; rev=\"describedby\"\nContent-Length: 10858\n\n\n\n---++++Example 2\n\n\ncurl -L -I -H \"Accept: text/n3\" http://localhost:8894/id/state/MA \nHTTP/1.1 303 See Other\nServer: Virtuoso/06.02.3129 (Win32) i686-generic-win-32 VDB\nConnection: close\nContent-Type: text/html; charset=ISO-8859-1\nDate: Wed, 04 May 2011 13:46:25 GMT\nAccept-Ranges: bytes\nLocation: http://localhost:8990/page/state/MA\nContent-Length: 0\n\nHTTP/1.1 303 See Other\nServer: Virtuoso/06.02.3129 (Win32) i686-generic-win-32 VDB\nConnection: Keep-Alive\nContent-Type: text/html; charset=UTF-8\nDate: Wed, 04 May 2011 13:46:25 GMT\nAccept-Ranges: bytes\nTCN: choice\nVary: negotiate,accept\nLocation: http://localhost:8990/sparql?query=define%20sql%3Adescribe-mode%20%22LOD%22%20%20DESCRIBE%20%3Chttp%3A%2F%2Flocalhost%\nMA%3E&format=text%2Fn3\nContent-Length: 0\n\nHTTP/1.1 200 OK\nServer: Virtuoso/06.02.3129 (Win32) i686-generic-win-32 VDB\nConnection: Keep-Alive\nDate: Wed, 04 May 2011 13:46:25 GMT\nAccept-Ranges: bytes\nContent-Type: text/n3; charset=UTF-8\nContent-Length: 15\n\n\n\n---++Related\n\n * [[VirtTipsAndTricksGuide][Virtuoso Tips and Tricks Collection]]\n * [[VirtFacetBrowserInstallConfig][Virtuoso Faceted Browser Installation and Configuration Guide]]\n * [[VirtuosoFacetsWebService][Virtuoso Faceted Search & Find Engine User Guide]]\n * [[VirtuosoLODSampleTutorial][Faceted Navigation to Explore Virtuoso hosted Linked Data Usage Guide]]\n" . . "2017-06-13T05:37:16.189442"^^ . . "2017-06-13T05:37:16Z" . "2017-06-13T05:37:16.189442"^^ . "e32d0f4d642f26f228001a8ee0c003f1" . . . "VirtTipsAndTricksInstallPattern" . . . . . . . . "VirtTipsAndTricksInstallPattern" . "VirtTipsAndTricksInstallPattern" . . . . . . "2017-06-13T05:37:16Z" .