How to overcome root domain CNAME restrictions?

前端 未结 8 786
失恋的感觉
失恋的感觉 2020-12-04 05:23

We are hosting many web applications for our customers. As is obvious they want to use their own domains to refer to those applications, usually they want that any user tha

8条回答
  •  刺人心
    刺人心 (楼主)
    2020-12-04 06:03

    I see readytocloud.com is hosted on Apache 2.2.

    There is a much simpler and more efficient way to redirect the non-www site to the www site in Apache.

    Add the following rewrite rules to the Apache configs (either inside the virtual host or outside. It doesn't matter):

    RewriteCond %{HTTP_HOST} ^readytocloud.com [NC]
    RewriteRule ^/$ http://www.readytocloud.com/ [R=301,L]
    

    Or, the following rewrite rules if you want a 1-to-1 mapping of URLs from the non-www site to the www site:

    RewriteCond %{HTTP_HOST} ^readytocloud.com [NC]
    RewriteRule (.*) http://www.readytocloud.com$1 [R=301,L]
    

    Note, the mod_rewrite module needs to be loaded for this to work. Luckily readytocloud.com is runing on a CentOS box, which by default loads mod_rewrite.

    We have a client server running Apache 2.2 with just under 3,000 domains and nearly 4,000 redirects, however, the load on the server hover around 0.10 - 0.20.

提交回复
热议问题