elementor / static-html-output

Static HTML Output Plugin for WordPress
https://statichtmloutput.com
The Unlicense
124 stars 33 forks source link

Relative URLs and Base URLs not working when deploying to subdirectory on server #117

Closed Briscoooe closed 4 years ago

Briscoooe commented 4 years ago

Configurations

Firstly, here are the configurations I am using. These are the ones i have changed, all others are the same.

WP2Static version - Version 6.6.7

Deploy Static Website

Processing

The problem

The build and deployment is successful but none of the links do not go to the right place. I can view my static site at https://example.com/static/ but all the links redirect to the original site, without the /static/ prefix. For example when trying to link to the /about page, I am brought to https://example.com/about instead of https://example.com/static/about.

The base tag appears like this and i believe its correct

<base href="https://example.com/static/">

But none of the relative URLs work because they are all prefixed with a forward slash like this

<a href="/about/">

When I manually remove the forward slash like this, it works fine. This example suggests its the correct way to do it.

<a href="about/">

Is this an error in my configuration or an issue with the plugin?

Briscoooe commented 4 years ago

Hey just wondering if there's any update on this?

leonstafford commented 4 years ago

Hi @Briscoooe,

Sorry, been out of action a while.

There should be another similar issue to this in this repo of https://github.com/WP2Static/wp2static, where I explain a bit more about why it happens and recommended alternatives (ie, proxying requests to route to a subdir from (sub)domain which you deploy to.

So, in short, it's a limitation/issue with the plugin at the moment, trying to deploy and rewrite links to a subdirectory of target domain and not expected a solid fix anytime soon.

Briscoooe commented 4 years ago

The issue I am having is not limited to subdomains. If I have my wordpress site on www.mywp.com and I want to host the static site on Destination URL www.mystatic.com, the final static version still has absolute references to www.mywp.com.

With this setup, my wordpress site must be online at all times to serve the URLs that were not rewritten as relative.

leonstafford commented 4 years ago

Hi @Briscoooe, my apologies for not reading correctly.

In that case, please try this updated version of the plugin, which does a much better job of rewriting: https://github.com/WP2Static/static-html-output-plugin/files/4822705/static-html-output-plugin-6.6.21.zip

Note, plugin name is Static HTML Output. Suggest starting by using the Zip deploy method.

Briscoooe commented 4 years ago

I am currently on the latest version in the plugin store, is this version not sufficient?

Screen Shot 2020-08-04 at 15 53 45

humbletiger commented 4 years ago

I have written a plugin to address this. Not sure if it would help you or not.

https://github.com/EricP/static-html-output-post-deploy https://github.com/EricP/static-html-output-post-deploy/archive/rewrite.zip (download plugin)

This is for WP admin deployment only and not CLI as it uses the form data to grab the rewrite rules, and then applies them to the files on disk.

Briscoooe commented 4 years ago

@leonstafford I installed the version in your zip, now I don't even see an option for relative URLs.

Am i missing something? Also the docs are empty.

Screen Shot 2020-08-05 at 12 52 34

Briscoooe commented 4 years ago

@leonstafford any update on this?

leonstafford commented 4 years ago

@Briscoooe - no more relative URLs. I've gone into more detail about why in a few GH issues and possibly on the forum: https://staticword.press

Sorry for delay, I've still been out of action mostly for last month, starting to catch up now hopefully.

For Static HTML Output, minimal docs in readme of this repo. Old docs which should still be of use at https://docs.wp2static.com for now.

Going to be redoing docs for all 3 WP -> Static projects I'm maintaining

Briscoooe commented 4 years ago

ok no problem.

Thank you for the help!