Reputation: 14283
I'm trying to write a regex to match parts of urls and use a SEO redirection wordpress plugin to create a 301 redirect on the matching results.
if, for example, I write these URLs:
https://www.test.com/my-site
https://www.test.com/my-site/
I want to be redirect to:
https://www.test.com/your-site/
but if the urls are followed by an hash (#) like the one below:
https://www.test.com/my-site/#/..
Do not redirect.
I have played around for a bit with regExr and this is as far as I could get:
But when try to implement it inside the plugin the redirect doesn't work.
What am i doing wrong here? Is it better to do it straight inside the .htaccess file? would it be better and more robust/reliable that way?
Thanks
Upvotes: 1
Views: 45
Reputation: 2465
The hash is never sent by the browser.
The hash is used internally by the browser to see which fragment of the document is focused on. This is called fragment identifier. This means your server will never see the # coming up. You cannot prevent this behavior.
Upvotes: 1