How to set my R2 domain to custom page

I’m currently using R2 Cloud with a custom domain. When I open the main domain, it leads to a 404 error. I want to redirect that R2 custom domain to a some custom page of other domain. However, I also need to ensure that subdirectories and files within the main domain still function as usual. I’ve attempted some Rewrite rules and setting a custom 404 page, but haven’t had success. Can you provide guidance or assistance with rewriting or modifying these rules effectively

RewriteEngine On
RewriteCond %{HTTP_HOST} ^yourmaindomain\.com [NC]
RewriteCond %{REQUEST_URI} ^/$
RewriteRule ^(.*)$ http://yourcustomdomain.com/ [L,R=301]

ErrorDocument 404 /custom404.html

Hey there,
The main domain of a custom R2 domain is not meant to be accessible, which is why you are seeing a 404 page. I believe that adding a redirection to this subdomain is not possible. To access the contents of your R2 bucket you will need to reference the name of the resource in the path of the URL. I recommend taking a look at this document: