问题原文
原帖链接 · homer · CC BY-SA 3.0
I have a main domain name : maindomain.com, on which I can access DNS configuration and current linked server (only files, not configuration) and a "cdn" domain (not one the same domain) cdn.domain.com on which I can access nearly everything
I want to transparent redirect request to subdomain (i.e. maindomain.com still in adress bar but cdn.domain.com reached) to reach my website on symfony
What I tried :
A 301 Redirect : (.htaccess)
RewriteEngine On
RewriteRule (.*) http://cdn.domain.com/$1 [R=301,L]
But this is not transparent as the URL change
A Proxy redirect : (.htaccess)
RewriteEngine On
RewriteRule ^(.*)$ http://cdn.domain.com/$1 [P]
But this doesn't seems to be activated on main server
I have some other solution to try, but I don't know if this could work and to avoid breaking the server I would like to know if this could work.
Edit server name in configuration and set DNS
<VirtualHost *:80>
ServerName maindomain.com
</VirtualHost>
maindomain.com intead of current cdn.domain.com.
And make DNS pointing to the server IP.
Can this configuration break other subdomains?
https://stackoverflow.com/questions/43632105/transparent-redirection-from-domain-to-subdomain
Externalise Symfony assets
As I don't have enough space on maindomain.com current server, I wanted to
know if I could only store the whole site structure except assets (a
part of web/ directory ? And how this would work for file upload ?
Furtherome is this viable (time complexity) with an external database
(stored on cdn.domain.com) ?
已采纳解答
原帖链接 · Simon Hayter · CC BY-SA 3.0
Transparent Redirects do not exist on planet Earth
As mentioned in the comment there's no such thing as a transparent redirect, it either redirects or it doesn't.
CNAME Records for MASKING Domain
The method that your most likely looking for is a DOMAIN MASK, which doesn't redirect but fetches the content from the original domain without changing the website address. This is normally done using a CNAME record that points to the main domain.
Apache Multiple ServerAlias
The other option is that rather than using a MASK or Redirect you can simply tell your Apache to host the same content on both domains using multiple ServerAlias's, for example:
ServerAlias *.exampleA.com *.eampleB.com
摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。
