Apache Rewrite Rules & Physical Directories

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi Apache Users,

I'm a newb with apache and could use some help. I'm using per
directory rewrites and delivering files via RDF and HTML using apache
.htaccess.

Here's my situation:

I have several independent html & rdf files in a directory named "/verbs/"

For example,

/verbs/answered.html, answered.rdf, answered.jsonld
/verbs/asked.html, asked.rdf, asked.jsonld

I also have a singe representation list of these same verbs, but as
one html named index.html

For example,

/verbs/index.html

I would like to be able to GET both the independent verbs and the
entire list using Accept header request.

I can currently GET the independent terms and it returns the
appropriate content type based on the Accept request

For example,

curl --header "Accept: application/rdf+xml" -L
http://example.com/adl/verbs/answered

However, if I attempt to GET the entire list of verbs it ALWAYS
returns HTML. For example,

curl --header "Accept: application/rdf+xml" -L http://example.com/adl/verbs

I have two .htacces files. One is at the /verbs/ directory level and
one is up a higher directory. The .htaccess at the higher directory is
pasted below.

It appears that my problem is that I have an actual physical directory
with the same name "/verbs/" as my Rewrite rule name ^verbs$. For
example, if I change the rewrite rule name to ^verbset$ my GET
requests work fine and return any of the content types that are
requested.

I would rather not work around this by naming the rewrite rule name,
and would prefer to learn more about apache instead of trying to apply
dated linked data recipes. Are there any specific directives that
might be causing this conflict? Or is it a limitation that rewrite
rule names can't be the same name as physical directories on the
server? Thanks in advance for any advice or resources!


# Turn off MultiViews
Options -MultiViews

# Rewrite engine setup
RewriteEngine On

# Directive to allow Cross origin requests
Header add Access-Control-Allow-Origin "*"
Header add Access-Control-Allow-Headers "origin, x-requested-with, content-type"
Header add Access-Control-Allow-Methods "PUT, GET, POST, DELETE, OPTIONS"
# Directive to ensure *.rdf files served as appropriate content type,
# if not present in main apache config
AddType text/html .html
AddType application/rdf+xml .rdf
AddType  text/turtle   .ttl
AddType application/ld+json .jsonld

RewriteBase /


# 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 ^verbs$ http://example.com/adl/verbs/index.html [R=303]

# Rewrite rule to serve RDF/XML content from the vocabulary URI if requested
RewriteCond %{HTTP_ACCEPT} application/rdf\+xml
RewriteRule ^verbs$ http://example.com/adl/verbs.rdf [R=303]

# Rewrite rule to serve Turtle content from the vocabulary URI if requested
RewriteCond %{HTTP_ACCEPT} text/turtle
RewriteRule ^verbs$ http://example.com/adl/verbs.ttl [R=303]

# Rewrite rule to serve JSON-LD content from the vocabulary URI if requested
RewriteCond %{HTTP_ACCEPT} application/ld\+json
RewriteRule ^verbs$ http://example.com/adl/verbs.jsonld [R=303]

# Choose the default response
# ---------------------------

# Rewrite rule to serve the RDF/XML content from the vocabulary URI by default
RewriteRule ^verbs$ http://example.com/adl/verbs/index.html [R=303]

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@xxxxxxxxxxxxxxxx
For additional commands, e-mail: users-help@xxxxxxxxxxxxxxxx




[Index of Archives]     [Open SSH Users]     [Linux ACPI]     [Linux Kernel]     [Linux Laptop]     [Kernel Newbies]     [Security]     [Netfilter]     [Bugtraq]     [Squid]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Samba]     [Video 4 Linux]     [Device Mapper]

  Powered by Linux