0

I have a Polymer site for which I need to write a rewrite rule.

Currently there is example.com/index.html#contact, example.com/index.html#FAQ and so on. It works by default in the browser as example.com/#contact, example.com/#FAQ, ...

I want it to be accessible as example.com/contact, example.com/FAQ, ...

I have:

RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.+)$ index.html#$1 [NE]

However, when I add the R flag to the last line it "works". Unfortunately, with the R flag the address becomes visible in the browser as example.com/index.html#home and I don't want that.

Any suggestions?

1 Answers1

0

You can't use htaccess or mod_rewrite to remove URL fragments because they are never sent to the server. As far as the server is concerned, they don't exist. You'll need to use javascript or some other client side solution to remove them.

Remove fragment in URL with JavaScript w/out causing page reload

Community
  • 1
  • 1
Amit Verma
  • 40,709
  • 21
  • 93
  • 115
  • Thanks, that is very interesting. In fact, I might need that later on. For now, I'm just trying to internally redirect the /foo to index.html#foo on the server. – Frank Vermeulen Jun 30 '16 at 21:45