simply-static icon indicating copy to clipboard operation
simply-static copied to clipboard

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

Open sr293 opened this issue 2 years ago • 12 comments

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

sr293 avatar Apr 17 '23 16:04 sr293

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

igorbenic avatar Apr 19 '23 19:04 igorbenic

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

chrisdavidmiles avatar Apr 20 '23 02:04 chrisdavidmiles

@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).

patrickposner avatar Apr 24 '23 08:04 patrickposner

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

chrisdavidmiles avatar Apr 28 '23 12:04 chrisdavidmiles

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

derekperkins avatar May 11 '23 20:05 derekperkins

@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

chrisdavidmiles avatar Jun 05 '23 13:06 chrisdavidmiles

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

  • Thanks

rpardz avatar Sep 27 '23 19:09 rpardz

Is there any update on this issue?

rpardz avatar Nov 24 '23 13:11 rpardz

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?

isatisfy avatar Aug 01 '24 11:08 isatisfy

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

rpardz avatar Aug 01 '24 13:08 rpardz

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.

derekperkins avatar Nov 06 '24 23:11 derekperkins

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

rpardz avatar Nov 17 '24 16:11 rpardz