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

Plain text _header and _redirect Netlify config files are being saved as index.html files #138

Open
sr293 opened this issue Apr 17, 2023 · 12 comments · Fixed by #270
Open
Assignees
Labels
bug Something isn't working
Milestone

Comments

@sr293
Copy link

sr293 commented Apr 17, 2023

When including a plain text config file with no extension for compatible services (Netlify, Gitlab Pages, Cloudfront Pages, etc.) the file is being treated like an HTML page which is producing an incorrect filename.

Example:
~/_redirects gets changed to ~/_redirects/index.html

It appears to be treated like an HTML page endpoint and not a file. When a file extension is present, like on ~/robots.txt, the generated file works as expected.

Steps to replication:

  1. Create a WordPress site and install the simply-static plugin
  2. Add a plain text file called _redirects with any text content to your document root so that it's visible at example.com/_redirects (example file)
  3. Include the _redirects URL in the simply static includes list in /wp-admin/
  4. Generate a static site
  5. The generated site will save the file as _redirects/index.html instead of _redirects, and because of the changed filename, the file won't be recognized as a configuration file by platforms like Netlify, Gitlab pages, etc.

The redirect file in root with no file extension:
image

Generated folder and index.html from file:
image

Site info from test site:
siteinfo.txt

@patrickposner patrickposner added this to the 2.2 milestone Apr 17, 2023
@igorbenic
Copy link
Collaborator

Hi @sr293, since _redirects is a file, not an URL, if I place it under "Additional Files and Directories" it works as intended.

Was that set as well there or as "Additional URL"?

Setting:
Screenshot 2023-04-19 at 21 05 07

Static Export:
Screenshot 2023-04-19 at 21 05 15

@chrisdavidmiles
Copy link

I used the Additional Files and Directories setting and it did not work. The files were unfortunately renamed. In this example I'm using Local by Flywheel to more closely match your test example. In your screenshot it appears to be working how I would want it to. Is there some other setting I should change or update?

Here is the debug log export from my test.

e7bec62e-d58a-492c-9ad0-1dc74749d41d

19aaf66a-c40f-4ce0-8b58-9b20ce4aac14

@patrickposner
Copy link
Collaborator

@chrisdavidmiles

I couldn't replicate it now with the next release (tested on Linux + Mac with LocalWP) and exported it as ZIP and Local Directory.

I also switched to multiple locations for the export to be sure it's not an edge case from the path itself.

So as long as these files are included in Simply Static -> Settings -> Include/Exclude -> Additional Files and Directories, that should work well.

There might be some issues from the filesystem that we can't replicate (maybe a .htaccess file blocks placing files in the root?), but nothing is blocking from within Simply Static anymore (next release).

@chrisdavidmiles
Copy link

@patrickposner

That's great news! When do you expect the new version with the fix to be released? I'm currently using version 2.3.0.

@patrickposner patrickposner modified the milestones: 2.2, 2.4 May 8, 2023
@derekperkins
Copy link

Great to hear, we're manually copying these files in now for Cloudflare Pages

@chrisdavidmiles
Copy link

@patrickposner you mentioned this was fixed in the next release, but the bug still exists on version 2.3.1.

Any update on this?

a24c2f9b-cf7c-499a-8325-fceffaf724dd

@patrickposner patrickposner added the bug Something isn't working label Jun 15, 2023
@rpardz
Copy link

rpardz commented Sep 27, 2023

Has this issue been fixed, I'm finding _redirects being converted into /_redirects/index.html

  • Thanks

@rpardz
Copy link

rpardz commented Nov 24, 2023

Is there any update on this issue?

@isatisfy
Copy link

isatisfy commented Aug 1, 2024

Great to hear, we're manually copying these files in now for Cloudflare Pages

Hi @derekperkins. Since this is still an unresolved issue in Simply Static, how were/are you copying the files manually into Cloudflare Pages?

@rpardz
Copy link

rpardz commented Aug 1, 2024

@isatisfy The only way I've got it to work is to unzip the simplystatic folder and then rename the _/redirects/index.html file to _redirects and move it into the root (out of the _/redirects/ folder). I then upload the whole simplystatic export.

@derekperkins
Copy link

Sorry for the late reply, but we do exactly what @rpardz suggested. We're working through some issues with the GitHub integration, and my hope is that we can add those files there, so we don't have to keep manually copying them.

@rpardz
Copy link

rpardz commented Nov 17, 2024

Just tested this today and it has not been fixed. Exporting _redirects still converts to a folder /_redirects/ with an index.html enclosed.
Screenshot 2024-11-17 at 11 32 56

@patrickposner patrickposner reopened this Nov 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

7 participants