I am trying to create a gatsby blog and calling Wordpress api similar to https://frugalisminds.com . Can i do a redirects from https://www.frugalisminds.com to non www website.
Struggling to Handle Redirects like we do in Wordpress Blogs.
I am trying to create a gatsby blog and calling Wordpress api similar to https://frugalisminds.com . Can i do a redirects from https://www.frugalisminds.com to non www website.
Struggling to Handle Redirects like we do in Wordpress Blogs.
There are a few ways you can do this:
You can set a redirect using Cloudflare. Learn more about that here.
Remix a node project, like this one, and add the following code to your index.js file:
const path = require("path");
const fastify = require("fastify")({
logger: false,
});
fastify.get("/", function (request, reply) {
reply.redirect('https://your_website_here')
});
fastify.listen(
{ port: process.env.PORT, host: "0.0.0.0" },
function (err, address) {
if (err) {
fastify.log.error(err);
process.exit(1);
}
console.log(`Your app is listening on ${address}`);
fastify.log.info(`server listening on ${address}`);
}
);
(replacing “your_website_here” with your site’s url of course), then add the domain you want to redirect to the custom URL tab of the project.