Mod rewrite with anchor

I have this addrress
http://mysite.com/index.php?cat=7

I write this mod rewrite

 RewriteRule ^category/(\d+) index.php?cat=$1

this means: if someone opens my adrress, his automatically he goes to the address:

  http://mysite.com/category/7

but i need use anchor also, that is, i need at the opening my address, happened redirected to this address:

 http://mysite.com/category/7#!somesome

Tell me please, how to write such RewriteRule ?

Upvotes: 0

Views: 98

Answers (1)

biril
biril

Reputation: 1995

If I correctly understand your question, you want to acquire the URL fragment (the part of the URL after the #) using (Apache's) mod rewrite.

Unfortunately this cannot be done. According to Wikipedia's article:

The fragment identifier functions differently than the rest of the URI: namely, its processing is exclusively client-side with no participation from the server

and

When an agent (such as a Web browser) requests a resource from a Web server, the agent sends the URI to the server, but does not send the fragment.

You'll have to work around this issue, probably using (client-side) javascript.

Upvotes: 1

Related Questions