0

How to remove a specific string from URL in .htaccess file.

For example my root URL is www.example.com. If someone puts www.example.com/# , it should redirect to root URL.

I have tried with

RewriteEngine on 
RewriteBase / 
RewriteRule ^#/(.*) /$1 [R=302,L]

1 Answer 1

1

The hash in the URL isn`t sent to the server when requesting a page, so you can't use redirect rules like that. It's client-side only.

You can change the url only with javascript:

if (location.href.indexOf("#") > -1) {
    location.assign(location.href.replace(/\/?#/, ""));
}
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.