0

I've a backlink of my website as

http://localhost/babycare/article/detail/93#591

I want to redirect it to a new user-friendly url like

http://localhost/babycare/article/detail/feeding_aversion

The code i've written in my .htaccess file is here

RewriteCond %{THE_REQUEST} /article/detail/93 [NC] 
RewriteRule ^/?(babycare)? /article/detail/Feeding_Aversion? [R=301]

But it redirects to

http://localhost/babycare/article/detail/feeding_aversion#591

How could i remove #591 from url.

Jay Blanchard
  • 34,243
  • 16
  • 77
  • 119
Arif Sami
  • 307
  • 1
  • 2
  • 14
  • # is not part of server-side redirection as it's not sent to the server. You can use javascript to manipulate fregment. – Amit Verma Feb 13 '17 at 13:54
  • but this code is written in .htaccess file. I want to remove it with regex if there is any method? – Arif Sami Feb 13 '17 at 13:56

1 Answers1

1

The problem you've got is that location hashes usually only exist in the browser, and are not meant to be handled by the server.

Its covering in more detail in the following answers;

URL Fragment and 302 redirects

Which one is better pushstate or location.hash?


You could use Javascript to remove the hash's if they're that much of an issue.

location.hash = "";

Should achieve what you're looking for - obviously it'll need to go onto each page.

Community
  • 1
  • 1
Tom
  • 4,257
  • 6
  • 33
  • 49