Simply-Static / simply-static

Convert your WordPress site into a static one with the free WordPress static site generator plugin, Simply Static.
https://simplystatic.com
GNU General Public License v2.0
200 stars 49 forks source link

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

Open sr293 opened 1 year ago

sr293 commented 1 year ago

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

igorbenic commented 1 year ago

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 commented 1 year ago

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 commented 1 year ago

@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 commented 1 year ago

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

derekperkins commented 1 year ago

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

chrisdavidmiles commented 1 year ago

@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

rpardz commented 1 year ago

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

rpardz commented 1 year ago

Is there any update on this issue?

isatisfy commented 4 months ago

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 commented 4 months ago

@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 commented 3 weeks ago

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 commented 2 weeks ago

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