I'm using the pathprefix option to deploy a site to a seperate folder on the server. This is then mapped/passed through using some apache config to make it look like it's at root of the domain.
What this means is when the page is loaded it will redirect to /{pathprefix} instead of just using root /
If i turn JS off the index.html page loads and the URL in the address bar doesn't change
See example here wwwpreprod.bristol.ac.uk (uses path prefix of homepage-preprod/)
Folder has been deployed to wwwpreprod.bristol.ac.uk/homepage-preprod but the server has been set up so any requests for /index.html are served from /homepage-preprod
Anyway of changing this behaviour?
System:
OS: Windows 10
CPU: x64 Intel(R) Core(TM) i7-6820HQ CPU @ 2.70GHz
Binaries:
Yarn: 1.9.4 - C:\Program Files (x86)\Yarn\bin\yarn.CMD
npm: 5.6.0 - C:\Program Files\nodejs\npm.CMD
Browsers:
Edge: 41.16299.785.0
npmPackages:
gatsby: ^2.0.82 => 2.0.82
gatsby-image: ^2.0.22 => 2.0.25
gatsby-link: ^2.0.1 => 2.0.7
gatsby-plugin-netlify: ^2.0.6 => 2.0.6
gatsby-plugin-react-helmet: ^3.0.0 => 3.0.5
gatsby-plugin-sass: ^2.0.1 => 2.0.7
gatsby-plugin-sharp: ^2.0.6 => 2.0.17
gatsby-plugin-typescript: ^2.0.0 => 2.0.3
gatsby-plugin-webpack-bundle-analyzer: ^1.0.4 => 1.0.4
gatsby-source-datocms: ^2.0.1 => 2.0.1
gatsby-source-filesystem: ^2.0.1 => 2.0.12
gatsby-transformer-sharp: ^2.1.3 => 2.1.10
Hey @trickydisco78
I'm not sure I understand your question. Could you please elaborate a little more on the expected behaviour versus actual behaviour in this context?
hi,
If you go to this page: https://wwwpreprod.bristol.ac.uk you'll notice it redirects to wwwpreprod.bristol.ac.uk/homepage-preprod(homepage-preprod is the pathprefix)
I don't want this to occur. If i turn JS off you'll notice it still works but no redirect.
The server admin guys won't let me publish content to root so they given me a folder and they are and asked me to prefix the files in index.html with the folder.
@trickydisco78 if i'm reading this correctly and understanding your issue, when you use path prefix option with gatsby, you're instructing the build process to append the path you defined, which will be later resolved to a folder on the server and when you navigate to the url it will show you the contents and be able to navigate your site without breaking the navigation. With this particular issue what is happening is that as your site is still in pre-production, you deployed it to a specific folder and is being tested. When it goes live, you're going to build it normally, with the path prefix, as the folder is being hosted is homepage-preprod, or something like that. Then your server admin will have to make a redirect rule that will serve not from the root but from the folder in question. Something like this. I might be wrong about this, but once again that's my interpretation of the issue at hand.
Hi,
Thanks for the repsonse. We have 3 folder set up for the 3 environments
homepage-dev
homepage-prod
homepage
I'm using the path prefix option for the 3 environments (so a separate build with environment variables to append)
"build-dev": "cross-env-shell ENV_BUILD=development \"gatsby build --prefix-paths\"",
"build-preprod": "cross-env-shell ENV_BUILD=preprod \"gatsby build --prefix-paths\"",
for the live environment we deploy to /homepage but it will look like it's served from www.bristol.ac.uk
If you navigate to this page it looks like it redirects to /homepage. If you turn JS off this doesn't occur as it's just loading index.html presumably
I'm guessing this isn't really the use case for the path prefix option. The other option i had is to rename the output files but unfortunately i've found that it creates absolute paths to /static in css refs and js
We've gone live now. The first university homepage in the world to use gatsby (as far as i know)
the first of many i'm sure @trickydisco78. Also can we close this one?
Before this gets closed: I think I'm seeing the same issue and I'm wondering if there's anything I can do to prevent it at the Gatsby level. (Happy to open a separate issue if that's preferred.)
I'm deploying my site to http://somewhere.s3-website-us-east-1.amazonaws.com. For $REASONS, I'm also deploying a slightly modified copy of the index.html file generated by Gatsby to other.html, which can be seen at http://somewhere.s3-website-us-east-1.amazonaws.com/other.html. Unfortunately, viewing other.html changes the browser's URL to the root and subsequent refreshes result in the user seeing the incorrect page.
Hiya!
This issue has gone quiet. Spooky quiet. 馃懟
We get a lot of issues, so we currently close issues after 30 days of inactivity. It鈥檚 been at least 20 days since the last update here.
If we missed this issue or if you want to keep it open, please reply here. You can also add the label "not stale" to keep this issue open!
Thanks for being a part of the Gatsby community! 馃挭馃挏
Hey again!
It鈥檚 been 30 days since anything happened on this issue, so our friendly neighborhood robot (that鈥檚 me!) is going to close it.
Please keep in mind that I鈥檓 only a robot, so if I鈥檝e closed this issue in error, I鈥檓 HUMAN_EMOTION_SORRY. Please feel free to reopen this issue or create a new one if you need anything else.
Thanks again for being part of the Gatsby community!
Before this gets closed: I think I'm seeing the same issue and I'm wondering if there's anything I can do to prevent it at the Gatsby level. (Happy to open a separate issue if that's preferred.)
I'm deploying my site to http://somewhere.s3-website-us-east-1.amazonaws.com. For $REASONS, I'm also deploying a slightly modified copy of the index.html file generated by Gatsby to other.html, which can be seen at http://somewhere.s3-website-us-east-1.amazonaws.com/other.html. Unfortunately, viewing other.html changes the browser's URL to the root and subsequent refreshes result in the user seeing the incorrect page.
I'm having the same issue!
Nevermind, I had issues with nginx configuration.
Most helpful comment
We've gone live now. The first university homepage in the world to use gatsby (as far as i know)
https://www.bristol.ac.uk