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

How to make Apache/cPanel recognise all/any domains pointed to its wildname CNAME record?

· 52CE 我爱测

Setup: Server Domain: redir.example.com subdomain of above: * CNAME value of *.redir.example.com = redir.example.com <anything>.redir.example.com get served redir.example.com/index.php (but no URL Change in browser address bar, a…

问题原文

原帖链接 · DavChana · CC BY-SA 3.0

Setup:

  1. Server Domain: redir.example.com
    • subdomain of above: *
    • CNAME value of *.redir.example.com = redir.example.com
    • <anything>.redir.example.com get served redir.example.com/index.php (but no URL Change in browser address bar, as intended).
  2. Client Domain: example.xyz
    • subdomain of above: test
    • CNAME value of test.example.xyz = test.redir.example.com
    • Desired result of above: server at main domain receives the test.example.xyz.

Problem:

  1. test.example.xyz gets auto-redirects to http://test.example.xyz/cgi-sys/defaultwebpage.cgi
  2. Apache sitting at main domain serves a generic error page with cPanel Branding & text SORRY!, There has been a server misconfiguration. with response code 200 OK. This, i believe, Apache says it does not recognise test.example.xyz& thus does not know what folder/files it should serve for this request.

Can cPanel/Apache be forced to accept all incoming CNAME values?

Note:

  1. http://redirect.center does this. Try http://anything.redirect.center, the php code at https://github./...../index.php "gets" the value, & processes accordingly. I am struggling to achieve this above "gets" step. My .php can process only if it receives the URL.
  2. Another working example with redirect.center, with NO DNS records on their side, & them just processing the incoming URL based on URL itself.

    http://tex.lab.dc1.in/tags goes to https://tex.stackexchange.com/tags

    1. tex CNAME tex.stackexchange.com.opts-uri.redirect.center.
    2. redirect.center "gets" the full domain tex.lab.dc1.in, & processes it according to its php (fetching it CNAME value, setting headers & redirects etc..).

How does it "gets/receives" the domains pointed to itself via CNAME records? How has it configured its apache (yes, it uses Apache) to receive & serve all wildcard domains?

EDIT:

OK, found out that I also need to add the following code block in my httpd.conf file

<VirtualHost *:80>
     DocumentRoot /opt/redirect.center/public_html
     ServerName redirect.center

     <Directory /opt/redirect.center/public_html>
         AllowOverride None
         Require all granted
     </Directory>
</VirtualHost>

<VirtualHost *:80>
    DocumentRoot /opt/redirect.center/redirect
    ServerName alias.redirect.center
    ServerAlias *

    <Directory /opt/redirect.center/redirect>
        AllowOverride None
        Require all granted
    </Directory>
</VirtualHost>

So, now the question becomes, Can we edit/add https.conf files on cPanel?

已采纳解答

原帖链接 · Stephen Ostermiller · CC BY-SA 3.0

You are correct that you want to add a wild card server alias to your virtual host. However, adding ServerAlias * would try to capture all domains, not just subdomains. I think you really want to add ServerAlias *.redir.example.com.

Your hosting provider may or may not let you do this. There are options in cPanel that allow hosting providers to turn on or off the feature of adding server aliases. Your hosting provider may not allow it because adding the wrong thing could be a security risk. It could also break the entire shared server for everybody if you entered the wrong thing like ServerAlias *. See here for instructions.

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

资料来源与适用范围

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

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

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