: Redirection of page with # to a new page I am trying to redirect http://www.example.com/#blog to http://www.example.com/blog in WordPress but it doesn't work since the /#blog part is considered
I am trying to redirect www.example.com/#blog to www.example.com/blog in WordPress but it doesn't work since the /#blog part is considered part of the homepage.
Did you encounter this problem before?
More posts by @Jennifer507
1 Comments
Sorted by latest first Latest Oldest Best
since the /#blog consider as the part of the homepage
Everything after the # is called the fragment identifier. This part of the URL (ie. blog in this case) is not actually sent to the server (the browser strips it from the request), so you can't do this sort of redirect in your server-side logic (ie. regular WordPress redirect).
The fragment identifier can only be manipulated client-side. eg. with JavaScript.
There might be (probably is) a WordPress plugin that will do client-side redirects for you, or you can write some JavaScript code. For example:
<script>
if (location.href == 'http://www.example.com/#blog') {
window.location.replace('http://www.example.com/blog');
}
</script>
Note that this is not the same as an HTTP redirect. The client only sees the 200 OK HTTP status, not a 3xx status that is usual (and preferable) with a redirect.
Terms of Use Create Support ticket Your support tickets Stock Market News! © vmapp.org2024 All Rights reserved.