Preface:
I am at following address:
http://www.example.com/#contact
After successful contact form submission, the user is redirected to following address:
http://www.example.com/thanks
With the help of following code:
// Redirect to thank you page
redirect_to("thanks");
The function redirect_to() is defined as:
// Page redirection
function redirect_to($url)
{
if(isset($url) && $url != '')
{
header("Location: " . $url);
exit();
}
}
The htaccess rules for the thanks page are:
# Thanks Page
RewriteRule ^thanks/?$ thanks.php [QSA,L]
#RewriteRule ^thanks/$ thanks.php [QSA,L]
Problem:
The issue is the hash (#) character i.e. the fragment part is still sticking with the URL like:
http://www.example.com/thanks#contact
How does the part #contact
get stick with main URL if I am redirecting the page to thanks
?
How can we exclude/drop it either by htaccess or PHP or even through JS?