Very hard thing

I have looked up all the posts related to this and I don’t understand what was done and not sure it matches this situation.

On the DNS at CF I have (using fake names):

CNAME pretty.com to: foo.pages.dev (using the beta static site deployment at CF)
and have associated the “private domain” with the deployed site through the pages settings.

That works great.

Now, here is the hard part. At the original hoster (of pretty.com) is still a wordpress site that is a subdirectory of the previous host for pretty.com. Let’s call it pretty.com/bar.

I am happy to use any way of reaching the former pretty.com/bar but I don’t want to rehost it (just lots of additional sysops work I’d just as soon not do). The reason is that no user will ever need to type the url into a browser. They will click on a link on a page of my new foo.com. So, I can make the ref of the link anything I want.

Based on a tutorial post in the CF community here is what I did–that does not work:

create A record to bar.pretty.com to the IP address of the root for the previous hoster.
create a page rule for bar.pretty.com to forward to https://pretty.com/bar. This is the only place we reference the target subdirectory. I would be happy to dispense with the page rule and use: bar.pretty.com/bar because I’ll enter the link ref on a page of the new site. Would this work?

I am little confused because this might not be possible. We need to get to a subdirectory of public_html of the former hoster. Only the former hoster can do that routing. There is no way to do 101.234.77.105/bar. IP addresses are to sites, not folders in the file system at the site.

So there needs to be an url (text name) to the host. Then it should be possible to add the /bar directory reference to the url to form a link. Does the url need to be different than pretty.com (the desired url) and hosted in the DNS of the old wordpress hoster?

The post below seems to suggest I can use a subdomain created here at CF for this url. But, it doesn’t seem to work.

Here is that post: https://community.cloudflare.com/t/redirect-main-domain-to-new-hosting-ip-while-leaving-existing-xxx-on-current-url-ip/42216

Thanks for your help.

Can you post a screenshot of your DNS records and Page Rules if you have some?

You can redirect:

from domainA.com/foo to domainb.com/bar
from domainA.com/foo to domainA.com/bar
from foo.domainA.com/something to domainA.com/something
from foo.domainA.com/something to domainB.com/something
from foo.domainA.com/something to domainB.com/*
from foo.domainA.com/* to domainB.com/*

Okay, great.

Okay.

Okay.

The difference is between using a sub-directory /foo and sub-domain foo.example.com.
The “foo” directory can be inside the same public_html directory, but used as either sub-directory of example.com/foo or as a sub-domain foo.example.com/.

For example, to consider:

  • there are hosting providers with cPanel where sometimes, it creates a sub-domain directory “foo” outside of “public_html”
  • but also other where they create a sub-domain directory “foo” inside “public_html” directory

You would either need another “bar” directory inside existing directory “bar” (while having an A record for your sub-domain bar.prety.com.

Depending how the configuration is done at hosts/origin server to what to do with “bar” directory, should the host use it as a directory and acces to it as pretty.com/bar or as sub-domain like bar.pretty.com/.

Here you go:

The DNS:

The forwarding page rule:

So, one simple answer to your question is at the other host, the subdirectory is a physical subdirectory of public_html in the actual file system. So it is example.com/foo and not foo.example.com. The latter would need to be an explicit subdomain. The subdirectory (the first one) is just a path that the host can navigate–like lots of blogs might use to reach content.

None of the from/to redirects you propose seem to be able to work. On the new site hosted here at CF there are no subdirectories that have the required name.

Well–maybe it could be done. It does have paths that can be navigated. the redirect could either fake it and use a path that doesn’t exist since the redirect will go to a place that does exist at the other host. Or, I could certainly create a subdirectory in the new site that contains a post that will not be displayed (easy to do…). Problem in both cases is that the generated site will not include an empty dir because there is nothing to put into it. So, this would also be “faking it.”

FIXED: must create the custom domain and “activate” it within the Pages settings. Not sure why but that’s how it works.

I should also point out that in the DNS:

lewislevin.com works and resolves to llcom.pages.dev

but:
www.lewislevin.com does not work and gets a not found.

It could be that the record hasn’t propagated to enough dns’s.

I followed what I did for another domain hosted here at CF.

It could be that I must refer to the domain in the settings at CF Pages.

For me it works!

Thats most probably the case

1 Like

Good about that one :+1:

1 Like

This is very old now.

I couldn’t really find a way to do this.

So, I generated a static version of the WordPress site with an amazing (and free) plugin. The fidelity is essentially perfect. Even all the comments appear correctly with each post. And the commenting UI is there—but static. So, nothing can ever change (uh, I guess that is the meaning of static) but it looks the same as it did before. It was not an active site so this is ok. Some day I’ll do something else with it but this is good for now. The static pages are hosted as a Pages site at CloudFlare. There is a null generate command: what’s done is done.