-1

I want to redirect a URL like

https://www.domain.com/#new

to

https://www.domain.com/new.html

How can I use .htaccess?

techraf
  • 64,883
  • 27
  • 193
  • 198
  • What did you try? Did you expect someone does the job without any effort from your part? – Al Foиce ѫ Oct 12 '16 at 15:02
  • Possible duplicate of [How to Detect and Redirect from URL with Anchor Using mod\_rewrite/htaccess?](http://stackoverflow.com/questions/3408664/how-to-detect-and-redirect-from-url-with-anchor-using-mod-rewrite-htaccess) – showdev Oct 14 '16 at 16:59

1 Answers1

0

Unfortunately the hash part of the URL is not being sent by the browser to the server, so in the server you can't really use this part to do the redirect.

You will have to use javascript code for that:

hash = window.location.hash
if (hash.length > 0) {
    window.location = '/' + hash.substr(1) + '.html'
}
Dekel
  • 60,707
  • 10
  • 101
  • 129