Hello there.
I'm using Aapanel with Nginx on my multi site server, CMS: Wordpress.
I ran an On Page SEO check on my site using sitechecker.pro, and I got a Criticals about Accessible index page: Redirect from index pages (.html and .php) configured incorrectly.
Image: https://imgur.com/kHl5Ic4
How can I do the redirect correctly?
PS: site.com/index.php Redirect to site.com
site.com/index.html does not Redirect to site.com, it opens the default index.html page
Congratulations, the site was created successfully!
This is my site Config:
server {
listen 80;
listen 443 ssl http2;
server_name www.site.com;
$scheme will get the http protocol
and 301 is best practice for tablet, phone, desktop and seo
return 301 $scheme://site.com$request_uri;
}
server
{
listen 80;
listen 443 ssl http2;
server_name site.com;
index index.php index.html index.htm default.php default.htm default.html;
root /www/home/site.com;
#SSL-START SSL related configuration, do NOT delete or modify the next line of commented-out 404 rules
#error_page 404/404.html;
ssl_certificate /www/server/panel/vhost/cert/site.com/fullchain.pem;
ssl_certificate_key /www/server/panel/vhost/cert/site.com/privkey.pem;
ssl_protocols TLSv1.1 TLSv1.2 TLSv1.3;
ssl_ciphers EECDH+CHACHA20:EECDH+CHACHA20-draft:EECDH+AES128:RSA+AES128:EECDH+AES256:RSA+AES256:EECDH+3DES:RSA+3DES:!MD5;
ssl_prefer_server_ciphers on;
ssl_session_cache shared:SSL:10m;
ssl_session_timeout 10m;
add_header Strict-Transport-Security "max-age=31536000";
error_page 497 https://$host$request_uri;
#SSL-END
set $skip_cache 0;
if ($request_method = POST) {
set $skip_cache 1;
}
if ($query_string != "") {
set $skip_cache 1;
}
if ($request_uri ~* "/wp-admin/|/xmlrpc.php|wp-.*.php|/feed/|index.php|sitemap(_index)?.xml") {
set $skip_cache 1;
}
if ($http_cookie ~* "comment_author|wordpress_[a-f0-9]+|wp-postpass|wordpress_no_cache|wordpress_logged_in") {
set $skip_cache 1;
}
location ~ [^/]\.php(/|$)
{
try_files $uri =404;
fastcgi_pass unix:/tmp/php-cgi-81.sock;
fastcgi_index index.php;
include fastcgi.conf;
add_header Strict-Transport-Security "max-age=63072000; includeSubdomains; preload";
fastcgi_cache_bypass $skip_cache;
fastcgi_no_cache $skip_cache;
add_header X-Cache "$upstream_cache_status From $host";
fastcgi_cache WORDPRESS;
add_header Cache-Control max-age=0;
add_header Nginx-Cache "$upstream_cache_status";
add_header Last-Modified $date_gmt;
add_header X-Frame-Options SAMEORIGIN;
add_header X-Content-Type-Options nosniff;
add_header X-XSS-Protection "1; mode=block";
etag on;
fastcgi_cache_valid 200 301 302 1d;
}
location ~ /purge(/.*) {
allow 127.0.0.1;
allow "IP";
deny all;
fastcgi_cache_purge WORDPRESS "$scheme$request_method$host$1";
}
#ERROR-PAGE-START Error page configuration, allowed to be commented, deleted or modified
#error_page 404 /404.html;
#error_page 502 /502.html;
#ERROR-PAGE-END
#PHP-INFO-START PHP reference configuration, allowed to be commented, deleted or modified
include enable-php-81.conf;
#PHP-INFO-END
#REWRITE-START URL rewrite rule reference, any modification will invalidate the rewrite rules set by the panel
include /www/server/panel/vhost/rewrite/site.com.conf;
#REWRITE-END
# Forbidden files or directories
location ~ ^/(\.user.ini|\.htaccess|\.git|\.svn|\.project|LICENSE|README.md)
{
return 404;
}
# Directory verification related settings for one-click application for SSL certificate
location ~ \.well-known{
allow all;
}
# protect xmlrpc.php
location = /xmlrpc.php {
deny all;
access_log off;
log_not_found off;
}
# protect wpconfig.php
location = /wp-config.php {
deny all;
access_log off;
}
# protect debug.log
location = /debug.log {
deny all;
access_log off;
}
location ~* /(?:uploads|files|wp-content|wp-includes)/.*.php$ {
deny all;
access_log off;
log_not_found off;
}
location ~ .*\.(gif|webp|jpg|jpeg|png|bmp|swf)$
{
expires 30d;
error_log /dev/null;
access_log off;
}
location ~ .*\.(js|css)?$
{
expires 12h;
error_log /dev/null;
access_log off;
}
access_log /www/wwwlogs/site.com.log;
error_log /www/wwwlogs/site.com.error.log;
}
Thank you.