0

I'm having trouble with url rewriting. I have the following rule working fine:

RewriteRule ^([^/\.]+)/?/([^/\.]+)/?$ page.php?theme=$1&pg=$2 [L]

which displays the url as follows:

domain.com/theme/pg

What i need is for the the url to rewrite to domain.com/theme#pg I thought the below would work, but it doesn't:

RewriteRule ^([^/\.]+)/?#([^/\.]+)/?$ page.php?theme=$1&pg=$2 [L]

What am I doing wrong?

TH1981
  • 3,105
  • 7
  • 42
  • 78

1 Answers1

0

# in the URL is the client-side thing - you should not get that on the server at all. You can rewrite to the URL containing an anchor, as given e.g. here:

but not from the URL containing a # - that would not get to the server at all.

Community
  • 1
  • 1
icyrock.com
  • 27,952
  • 4
  • 66
  • 85
  • 1
    I _think_ Aninemity is trying to convert it to that. – GoldenNewby Feb 21 '12 at 02:20
  • @GoldenNewby Yeah, what he says in English and what the last `RewriteRule` says in Apacheconfigian (is that how we should call the Apache configuration language?) is contradictory. I assumed `RewriteRule` was correct - theres's a 50% chance I'm right :) and the other 50% are covered by the links I added - so we should all be set :) – icyrock.com Feb 21 '12 at 02:22
  • okay, so that's why my poor attempt didn't work. What i'm trying to do is have the rewrite rule change `domain.com/theme#pg` to `domain.com/page.php?theme=theme&pg=pg` sorry if i wasn't clear – TH1981 Feb 21 '12 at 02:43
  • Sorry, can't do that - take a look at this: http://blog.logeek.fr/2007/12/31/how-to-debug-rewrite-rules-with-apache, then after you configure as above try some URL requests from your browser and look what you get in the log file. Only what you get is something you can work off of. If you don't get the `#`, you cannot work with `#`. And since it's a client-only thing, you will not get it under normal circumstances (i.e. if you are using standard browsers). Testing yourself is best for learning, though :) – icyrock.com Feb 21 '12 at 02:49