1

I am having a difficult time figuring out how to have the following work:

  • I am trying to redirect a url in htaccess
  • I am trying to redirect from example.com/test.html to example.com/index#test

I have the following setup

RewriteRule ^test.html http://www.example.com/index#test [R=301,L,B]

However, it is not working because the browser redirects to http://www.example.com/index%23test and returns a page not found.

I have tried many different flags without success.

Thanks,

Andrew Schulman
  • 8,811
  • 21
  • 32
  • 47
AKKAweb
  • 149
  • 1
  • 5
  • This is not possible. A hash (#) is never sent to the server: https://en.wikipedia.org/wiki/Fragment_identifier, http://tools.ietf.org/html/rfc3986#section-3.5 – zhenech Jul 11 '14 at 19:11
  • 1
    It is possible. It works the other way around here. The server sends the URL with fragment identifier in the `Location` HTTP header. http://stackoverflow.com/questions/2286402/url-fragment-and-302-redirects answer has a more complete description on what happens. – Tero Kilkanen Jul 12 '14 at 08:30

1 Answers1

3

Actually, a friend help me out with this.

RewriteRule ^test.html http://www.example.com/index#test [R=301,NE,L]

Andrew Schulman
  • 8,811
  • 21
  • 32
  • 47
AKKAweb
  • 149
  • 1
  • 5