Learn about Centmin Mod LEMP Stack today
Become a Member

Nginx subdomain display 404?

Discussion in 'Nginx, PHP-FPM & MariaDB MySQL' started by jellday, Mar 30, 2016.

  1. jellday

    jellday Member

    May 31, 2014
    Local Time:
    8:43 PM
    server {
            server_name *.mydomainname.info;
            if ( $host ~* (\b(?!www\b)\w+)\.\w+\.\w+ ) {
                   set $subdomain /$1;
            location / {
                    root /home/nginx/domains/mydomainname.info/public$subdomain;
                    index index.html index.php;
            location ~ ^/(ads|d|e|skin)/
                    proxy_redirect        off;
                    proxy_set_header    Host   www.mydomainname.info;
      include /usr/local/nginx/conf/staticfiles.conf;
      include /usr/local/nginx/conf/php.conf;
      include /usr/local/nginx/conf/drop.conf;
      include /usr/local/nginx/conf/vts_server.conf;
      if ($http_user_agent ~* "(YisouSpider|EasouSpider|EtaoSpider)") {
       return 403;
    some subdomain is all right, but some are not.
    It seems to me that if the index file is index.html, then subdomain.mydomain.info is all right
    if the index file is index.php, then shows 404 error. Don't know why
  2. eva2000

    eva2000 Administrator Staff Member

    May 24, 2014
    Brisbane, Australia
    Local Time:
    10:43 PM
    Nginx 1.17.x
    MariaDB 5.5/10.x
    Centmin Mod is provide as is, so short of scripted related bugs or issues, any further optimisation to the web stack components - nginx, php-fpm, mariadb mysql, csf firewall etc or web app specific configurations are left to the Centmin Mod user to deal with. So I do not provide any free support for such.

    However, Centmin Mod users are free to help each other out and ask questions or give answers on this community forum. My hopes are that this community forum evolves so that more veteran long time Centmin Mod users help new Centmin Mod users out :)

    any clues in your access.log and error.log in vhost listed paths at
    Code (Text):
    access_log /home/nginx/domains/domain.com/log/access.log combined buffer=256k flush=60m;
    error_log /home/nginx/domains/domain.com/log/error.log;

    Not sure but try moving the root path out of root / to server context ?
    Code (Text):
    root /home/nginx/domains/mydomainname.info/public$subdomain;