I create subdomain on nginx ,I have made a configuration on sites-available and have also symlinked it to sites-enabled,
I have also added records to cloudflare, for exampleType: Aname : Blogcontent : IP
but when I opened a subdomain, the subdomain opened the root folder of the main domain even though I had already set it in the subdomain configuration like /var/www/panel/ while the one opened by the subdomain is /var/www/wordpress which is the root directory of the main domain
here the configuration of main domain
server { listen 80 default_server; listen [::]:80 default_server; server_name example.com www.example.com; root /var/www/wordpress; index index.php index.html index.nginx-debian.html; location / { try_files $uri $uri/ /index.php$is_args$args; } location ~ \.php$ { include snippets/fastcgi-php.conf; fastcgi_pass unix:/var/run/php/php8.1-fpm.sock; } error_log /var/log/nginx/example_error.log; access_log /var/log/nginx/example_access.log;}server { listen 443 ssl; listen [::]:443 ssl; server_name example.com www.example.com; ssl_certificate /etc/ssl/example.pem; ssl_certificate_key /etc/ssl/example.key; root /var/www/wordpress; index index.php index.html index.nginx-debian.html; location / { try_files $uri $uri/ /index.php$is_args$args; } location ~ \.php$ { include snippets/fastcgi-php.conf; fastcgi_pass unix:/var/run/php/php8.1-fpm.sock; } error_log /var/log/nginx/example_error.log; access_log /var/log/nginx/example_access.log;}
here the configuration of subdomain
server { listen 80; listen [::]:80; server_name panel.example.com www.panel.example.com; root /var/www/panel; index index.php index.html index.nginx-debian.html; location / { try_files $uri $uri/ /index.php$is_args$args; } location ~ \.php$ { include snippets/fastcgi-php.conf; fastcgi_pass unix:/var/run/php/php8.1-fpm.sock; }}