How to redirect if subdirectory contains hash Nuxt?
P粉277305212
P粉277305212 2023-09-07 10:24:26
0
1
622

At the request of SEO experts, I need to implement the following functions. I have to redirect if the link contains capital letters. For example https://domain.com/#Contacts ==> https//domain.com/#contacts.

In Nuxt, I do this by creating a function on the server.js file in the middleware folder.

But if the path contains hash(#), it will not work

export default function (req, res, next) {
    const url = req.url;

    if (url !== url.toLowerCase()) {
        res.writeHead(301, { Location: url.toLowerCase() });
        res.end()
    } else {
        next();
    }
}

I would be grateful if you answer or provide help

P粉277305212
P粉277305212

reply all(1)
P粉964682904

The hashed part (Fragment Identifier) is never sent to the server through the browser connection, so your attempt to use a redirect is impossible.

You can access them client-side, but I don't think that does any SEO good.

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template