大网数据广告活动
网站运营与故障问答

Transparent redirection from domain to subdomain

· 52CE 我爱测

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 near…

问题原文

原帖链接 · 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

摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。

资料来源与适用范围

资料来源
Webmasters Stack Exchange
适用范围
以原帖系统、软件版本与发布日期为准(2017-04-27)
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 3.0

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。