0

I have this url: mysite.com/account/user#editSucc, I want it to be parsed as mysite.com?goTo=account&section=user&msg=editSucc.

This is my .htaccess file:

RewriteEngine On
RewriteRule ^account/([A-Za-z-]+)$ /?goTo=account&section=$1 [L,NC]

How can I make the part with the # symbol? and merge it with the existing code?
Thanks.

Xriuk
  • 382
  • 2
  • 7
  • 26

1 Answers1

0

You can't do this using htaccess. The URL fragment (everything after #) is never sent to the server and thus nothing on the server's end even knows it exists. You need a strictly client side solution to deal with it. Since you want it to be redirected (and that's all you'll be able to do with it). you can try something like from this link:

<script type="text/javascript">
var parts = location.href.split('#');
if(parts.length > 1)
{
    location.href = '/?goTo=account&section=user&msg=' + parts[1];
}
Jon Lin
  • 142,182
  • 29
  • 220
  • 220