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

Deployment URL subdirectory is broken on same domain #573

Open
chozze opened this issue Jun 8, 2020 · 7 comments
Open

Deployment URL subdirectory is broken on same domain #573

chozze opened this issue Jun 8, 2020 · 7 comments
Labels

Comments

@chozze
Copy link

chozze commented Jun 8, 2020

Hi, I'm running version 7.0-alpha-007 and if I insert subdirectory under same domain, eg. on webserver http://example.com and Deployment URL is set to http://example.com/static then generated links are http://example.com/static/static/... instead of http://example.com/static/...

SimpleRewriter.php is broken

Thanks for your help, Ales

@leonstafford
Copy link
Contributor

Hi @chozze, I'd strongly suggest not using subdirectories for the WP hosting or deployment, the plugin struggles with them and I'm probably going to advertise that they're not supported.

ideally:

  • dev.example.com
  • example.com (or static.example.com) while you're testing

Will close this as a "won't fix", but please let me know if you're planning to host your production site in a subdirectory or otherwise are struggling to find a setup that works for you and I'll offer some suggestions/alternatives.

@chozze
Copy link
Author

chozze commented Jun 13, 2020

Thanks @leonstafford for replying, I would like to keep the static version in subdir of the site, so I guess eaiser solution is to write custom rewriter to run over all files again, replacing duplicated dirpath?

thanks Ales

@leonstafford
Copy link
Contributor

@chozze that will probably work OK. You can tap into one of the hooks available https://wp2static.com/developers/extending-wp2static/

I'm still not sure of your intended use case, but if for example, you have an existing non-WP site at the naked domain and you want to export this site to your subdir within that site, you may look to use rewriting at the hosting end. ie, if using CloudFront, Netlify or Cloudflare, you can have all requests to /mystaticsite/ reroute to another origin server, or if running Nginx, proxy requests to a different internal domain. Many options, please let me know if you get stuck for ideas.

@chozze
Copy link
Author

chozze commented Jun 14, 2020

@leonstafford it's a specific requirement for one client, who wants to use your plugin to generate a static site to specific directory on the same server. They will probably run another hooks after that to deploy it, zip it, archive it, or anything.

Ales

@leonstafford
Copy link
Contributor

@chozze, sorry, I was being too quick to dismiss/shoot down the issue. Shortcomings in the plugin's current state shouldn't dictate what areas get ignored. Whilst I'd prefer to push the dev sites to not be hosted within a subdirectory (dev sites having more flexibility, as not so public facing), for the deployment URL, the plugin should support any combination of subdomain.subdomain.domain.tld/subdir/subdir/

Now, thinking out loud based on recent work around URL rewriting, we have to deal with many types of links within a WP site

  • document relative image.jpg, ../image.jpg
  • site root relative /image.jpg
  • FQURL http://localhost/image.jpg
  • protocol-relative //localhost/image.jpg

a FQURL is ideal, if we can rewrite all of those to one, else if our dev site is example.com and we leave a site root relative URL of /image.jpg and serve that from example.com/blog, it's not going to be looking for that path within /blog/, but at the site's root, which is not part of our static site in this use case.

The plugin's doing a much better job now of detecting and rewriting URLs and with some automated tests to validate different input/output HTML/CSS files, it should be easier to track down the issues you're facing and write up a fix.

I'll try to get onto this soon and again, sorry for being a bit of a dick/dismissive of the issue!

@leonstafford leonstafford reopened this Jun 14, 2020
@leonstafford leonstafford added bug and removed wontfix labels Jun 14, 2020
@leonstafford leonstafford self-assigned this Jun 14, 2020
@chozze
Copy link
Author

chozze commented Jun 14, 2020

@leonstafford, no need to apologize at all!
Appreciated your openness and responsiveness to this issue.

RIght now, I am doing a dirty workaround by genereting static site by

wp wp2static options set deploymentURL PLACEHOLDER_SITE

and after post processing is complete, I crawl the destination URL again and replace the placeholder with a real server path.

@thegulshankumar
Copy link

thegulshankumar commented Jun 14, 2020

I thought to keep on same server two virtualhost name

dev.example.com at

/var/www/wp

And

example.com static under

/var/www/static/

I am not sure what can goes wrong with this. I feel this can save server cost if someone want 'author' role support (keeping WP online, pass protected) while enjoying benefit of static for public domain.

Do you think this approach can do faster deployment? As it may not need SFTP addon kind of thing if dir permission are same www-data:www-data for all two virtualhost root paths.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants