htaccess RewriteRule Hash# in URL

197 views
Skip to first unread message

Roger Rutishauser

unread,
Jul 23, 2018, 6:36:18 PM7/23/18
to Skosmos Users
Dear Skosmos Users

Not sure, if this is the right place for my problem...

The URI for an example concept is 

Therefore I need a rewriteRule in .htaccess in the root folder of http://vocab.example.com that will forward the user to the "real" page of the concept in Skosmos.

The problem: 

User will be forwarded to:
which will not work. 
If I replace the # with %23, it will work:

How can I make it work in htaccess? any hints?

Thank You
Roger

Richard Walker

unread,
Jul 23, 2018, 7:58:25 PM7/23/18
to Skosmos Users
On Tuesday, July 24, 2018 at 8:36:18 AM UTC+10, Roger Rutishauser wrote:
How can I make it work in htaccess? any hints?

Roger Rutishauser

unread,
Jul 24, 2018, 2:41:15 AM7/24/18
to Skosmos Users
Yes. It does not work.

I also tried this:

Everything from "#" onwards - #bestand - does not seem to be part of %{REQUEST_URI}

It does forward to 
because it shows the conceptScheme, not the concept

Richard Walker

unread,
Jul 24, 2018, 3:32:33 AM7/24/18
to Skosmos Users
On Tuesday, July 24, 2018 at 4:41:15 PM UTC+10, Roger Rutishauser wrote:
Yes. It does not work.

Oh, now I see the problem.

You can't get it to work this way, because the part of the URL from # onwards is not even sent to the server. Anchors are client-side.

For a URL http://vocab.example.com/htwchur/informationswissenschaft#bestand, the client removes the anchor before sending the request.

So the client sends the request to the server as http://vocab.example.com/htwchur/informationswissenschaft.

Your RewriteRule rewrites the request as http://skosmos.example.com/htwchur/de/page/?uri=http://vocab.example.com/htwchur/informationswissenschaft and sends the rewritten URL back to the client with a redirect status code.

The client then sends a request for the rewritten URL and gets back the response.

And then the client is supposed to apply #bestand to the result that comes back.

This is the "hash versus slash" debate for RDF resource IRIs. Just for this reason, slashes win.

You'll need to change your resource IRIs to use slashes, e.g.: http://vocab.example.com/htwchur/informationswissenschaft/bestand

(Hmm, maybe http://vocab.example.com/htwchur/informationswissenschaft%23bestand could work with [L,R=301,B], but even if it does work, that's probably not what you had in mind.)

Roger Rutishauser

unread,
Jul 24, 2018, 9:12:59 AM7/24/18
to Skosmos Users
Thank you Richard for this detailed explanation.
I changed everything from # to /
it works absolutly fine now.
Reply all
Reply to author
Forward
0 new messages