Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8365113
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T12:34:58+00:00 2026-06-09T12:34:58+00:00

Have a wildcard dns subdomain record. Using domain-only validation SSL certificate. Need to set

  • 0

Have a wildcard dns subdomain record. Using domain-only validation SSL certificate.
Need to set nginx rewrite rules in that way:

http://site.com   => https://site.com

http://*.site.com => http://*.site.com

I guess it is something like this

server {
    listen  80;
    server_name site.com *.site.com;
    if ($host ~* "^([^.]+(\.[^.]+)*)\.site.com$"){
        set $subd $1;
        rewrite ^(.*)$ http://$subd.site.com$1 permanent;
        break;
    }
    if ($host ~* "^site.com$"){
        rewrite ^(.*)$ https://site.com$1 permanent;
        break;
    }
    #rewrite    ^ https://$server_name$request_uri? permanent;
    charset utf-8;
}

server {

    listen   443;

    server_name  site.com;
    ssl On;
    ssl_certificate     /root/site.com.crt;
    ssl_certificate_key /root/site.com.key;

    location ~ \.php$ {
        fastcgi_pass   127.0.0.1:8888;
        fastcgi_index  index.php;
        fastcgi_param  SCRIPT_FILENAME  /var/www/site$fastcgi_script_name;
        fastcgi_param  QUERY_STRING     $args;
        include fastcgi_params;
    }

    location / {
        root   /var/www/site;
        index  index.php index.html;
        if ($host !~ ^(site.com)$ ) {
            return 444;
        }
        try_files $uri $uri/ /index.php?$args;
    }
}

It loops infinitely. What is the correct way to get this working ?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T12:34:59+00:00Added an answer on June 9, 2026 at 12:34 pm

    You should rewrite your server block into two parts.
    First part only for domain “site.com” and following redirection to https
    Second part, for all other domains, “*.site.com”

    server {
        listen  80;
        server_name site.com;
        rewrite ^(.*)$ https://site.com$1 permanent;
    }
    
    server {
        listen  80;
        server_name *.site.com;
        #etc... rewrites not necessary
    }
    

    So, your nginx.conf would be:

    server {
        listen  80;
        server_name site.com;
        rewrite ^(.*)$ https://site.com$1 permanent;
    }
    server {
        listen  80;
        server_name *.site.com;
        charset utf-8;
        # etc ...
    }
    
    server {
    
        listen   443;
    
        server_name  site.com;
        ssl On;
        ssl_certificate     /root/site.com.crt;
        ssl_certificate_key /root/site.com.key;
    
        location ~ \.php$ {
            fastcgi_pass   127.0.0.1:8888;
            fastcgi_index  index.php;
            fastcgi_param  SCRIPT_FILENAME  /var/www/site$fastcgi_script_name;
            fastcgi_param  QUERY_STRING     $args;
            include fastcgi_params;
        }
    
        location / {
            root   /var/www/site;
            index  index.php index.html;
            if ($host !~ ^(site.com)$ ) {
                return 444;
            }
            try_files $uri $uri/ /index.php?$args;
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

What I have currently: A wildcard DNS record. So that every subdomain points to
Say I have the following domain: example.com I have a Wildcard SSL certificate for
I have my DNS configured to accept any subdomain (wildcard *), but I am
I have a domain name with wildcard dns active. what i want to write
i have wildcard dns on my domain... and have following in my htaccess RewriteCond
I have a wildcard subdomain setup using CPanel, and I'd like to be able
I have configured the wildcard DNS of *.mydomain.com and it's all working properly. My
I have a domain with wildcard - *.mysite.com hosted on Server1 I am planning
I have a query that searches for clients using like with wildcard. For example:
Please can you advise whether we need a wildcard SSL or 2 separate SSL

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.