Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Redirect all non-www to www #13

Open
mathildebuenerd opened this issue May 23, 2020 · 3 comments
Open

Redirect all non-www to www #13

mathildebuenerd opened this issue May 23, 2020 · 3 comments

Comments

@mathildebuenerd
Copy link

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?

@kkroeger93
Copy link

kkroeger93 commented Oct 16, 2020

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. 👍

@teamrdx
Copy link

teamrdx commented Apr 28, 2021

same here. could not able to figure it out. Any help is extremely valuable. 😊 Thanks in advance

@koctalha
Copy link

Is there anybody to help us about this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants