gatsby-plugin-htaccess
gatsby-plugin-htaccess copied to clipboard
Redirect all non-www to www
I would like to redirect all non-www urls to www. I have issues with configuring the plugin in gatsby-config to acheive that. At the moment I cannot succeed in doing it, whenever I go to mydomain.com, I get a "Server not found" error and no redirection.
What I would put in the .htaccess would be the following code (it also redirects from http to https):
<IfModule mod_rewrite.c>
RewriteCond %{HTTPS} off [OR]
RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteCond %{HTTP_HOST} ^(.*)$ [NC]
RewriteRule (.*) https://www.mydomain.com/$1 [R=301,L]
</IfModule>
Is it supposed to be done only with setting the www
option to true?
{
resolve: "gatsby-plugin-htaccess",
options: {
https: true,
www: true,
host: "www.mydomain.com",
},
I have also tries with adding the redirect, but I still have no result:
{
resolve: "gatsby-plugin-htaccess",
options: {
https: true,
www: true,
host: "www.mathildebuenerd.dev",
redirect: ["RewriteRule (.*) https://www.mydomain.com/$1 [R=301,L]"],
},
},
What would be the correct way to configure this?
I'm also facing this issue right now. To solve it temporarily, I edited the .htaccess after the build process was done.
Would definitely be nice if this issue gets solved. 👍
same here. could not able to figure it out. Any help is extremely valuable. 😊 Thanks in advance
Is there anybody to help us about this?