0

I'm not sure why this doesn't work on my local Apache2 server.

When I tested with http://localhost/v1.0# It gives me:

The requested URL /v1.0 was not found on this server. Apache/2.4.18 (Ubuntu) Server at localhost Port 80

Options +FollowSymLinks
# Turn off MultiViews https://stackoverflow.com/a/25423722/646732
Options -MultiViews

# Directive to ensure *.rdf files served as appropriate content type,
# if not present in main apache config
AddType application/rdf+xml .rdf
AddType application/rdf+xml .owl
AddType text/turtle .ttl
AddType application/n-triples .n3
AddType application/ld+json .json

# Rewrite engine setup
RewriteEngine On

# code 308 permanent redirect, cacheable,
# The request method and the body will not be altered, 
# whereas 301 may incorrectly sometimes be changed to a GET method.
# https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/308

# flag https://httpd.apache.org/docs/2.4/rewrite/flags.html
# L|last If the rule matches, no further rules will be processed
# NE|noescape Do not convert to hexcode equivalent, i.e. # to %23
# OR Combine rule conditions with a local OR instead of the implicit AND

# http://httpd.apache.org/docs/current/mod/mod_rewrite.html#rewriterule

# make sure we don't have the file or a directory index to serve
# the rest fails to redirect if we do
RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule .* - [L]

# Rewrite rule to serve HTML content from the vocabulary URI if requested
# RewriteCond %{HTTP_ACCEPT} !application/rdf\+xml.*(text/html|application/xhtml\+xml)
RewriteCond %{HTTP_ACCEPT} text/html [OR]
RewriteCond %{HTTP_ACCEPT} application/xhtml\+xml [OR]
RewriteCond %{HTTP_USER_AGENT} ^Mozilla/.*
RewriteRule ^v0.1#(.*)$ https://miranda-zhang.github.io/cloud-computing-schema/v0.1/index.htm#$1 [R=308,NE,L]
RewriteRule ^v1.0#(.*)$ https://miranda-zhang.github.io/cloud-computing-schema/v1.0/index-en.html#$1 [R=308,NE,L]

# Rewrite rule to serve JSON-LD content from the vocabulary URI if requested
RewriteCond %{HTTP_ACCEPT} application/ld+json
RewriteRule ^v1.0#$ https://miranda-zhang.github.io/cloud-computing-schema/v1.0/ontology.json [R=308,L]

# Rewrite rule to serve RDF/XML content from the vocabulary URI if requested
RewriteCond %{HTTP_ACCEPT} \*/\* [OR]
RewriteCond %{HTTP_ACCEPT} application/rdf\+xml
RewriteRule ^v0.1#$ https://miranda-zhang.github.io/cloud-computing-schema/v0.1/ontology/cocoon.rdf [R=308,L]
RewriteRule ^v1.0#$ https://miranda-zhang.github.io/cloud-computing-schema/v1.0/ontology.xml [R=308,L]

# Rewrite rule to serve N-Triples content from the vocabulary URI if requested
RewriteCond %{HTTP_ACCEPT} application/n-triples
RewriteRule ^v1.0#$ https://miranda-zhang.github.io/cloud-computing-schema/v1.0/ontology.nt [R=308,L]

# Rewrite rule to serve TTL content from the vocabulary URI if requested
RewriteCond %{HTTP_ACCEPT} text/turtle [OR]
RewriteCond %{HTTP_ACCEPT} text/\* [OR]
RewriteCond %{HTTP_ACCEPT} \*/turtle
RewriteRule ^v0.1#$ https://miranda-zhang.github.io/cloud-computing-schema/v0.1/ontology/cocoon.ttl [R=308,L]
RewriteRule ^v1.0#$ https://miranda-zhang.github.io/cloud-computing-schema/v1.0/ontology.ttl [R=308,L]

RewriteCond %{HTTP_ACCEPT} .+
RewriteRule ^$ https://miranda-zhang.github.io/cloud-computing-schema/v1.0/406.html [R=406,L]

# Default response
# ---------------------------
# Rewrite rule to serve the RDF/XML content from the vocabulary URI by default
RewriteRule ^$ https://miranda-zhang.github.io/cloud-computing-schema/v1.0/ontology.xml [R=308,L]

Could that be I have a dot in my URL?

The old .htaccess works, I can't see anything obviously wrong.

Mzq
  • 1,796
  • 4
  • 30
  • 65

1 Answers1

1

You can't match the hash mark, since the browser doesn't send it to the server. It's for client-side use only.

covener
  • 17,402
  • 2
  • 31
  • 45