I have a website that has been built at say montypython.netlify.app
The client has their main website at holygrail.com
and they want holygrail.com/resources
to show the contents of montypython.netlify.app
but keep the URL the same. Which means that it should continue to show holygrail.com/resources
in the search bar.
This also means that any pages from montypython.netlify.app
should appear are subdirectories of holygrail.com/resources
Example:
montypython.netlify.app/about
should appear as holygrail.com/resources/about
I am guessing this has to do with editing the .htaccess at holygrail.com
but what rewrite/redirect rules can I reference? There are a lot of URLs so is there a wildcard approach I can use?
This is what I've tried:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{HTTP_HOST} ^holygrail\.com$ [NC]
RewriteRule ^resources/(.*)$ https://montypython.netlify.app/$1 [R=301,L]
</IfModule>
CodePudding user response:
Maybe your issue is with the line:
RewriteCond %{HTTP_HOST} ^holygrail\.com$ [NC]
Maybe you need to try to do something like
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_URI} !^/$
RewriteRule ^resources/(.*)$ https://montypython.netlify.app/$1 [R=301,L]
</IfModule>
CodePudding user response:
I have worked on projects in the past with similar objectives. I don't believe you can accomplish this with redirects. The suggestion about using a reverse proxy would be the most well aligned with your requirements, but there is another option that may also be useful. Some DNS providers offer "DNS Cloaking" or "Stealth Redirects". This can be configured so that requests for holygrail.com
will display a frame containing the content for montypython.netlify.app
. Could you use the same approach for the /resources
sub-directory, so that holygrail.com/resources
delivers a frame that loads montypython.netlify.app
?
The drawback to this is the address bar will not change as you navigate inside the frame, e.g. navigating to montypython.netlify.app/resources/about
will still show holygrail.com/resources
in the address bar, because it is displaying the address of the frame.