The Blog

The requested URL was not found on this server – WordPress


Change the /etc/apache2/apache2.conf file:

 # Protege a raiz do sistema
<Directory />
	Options None
	AllowOverride None
	Require all denied
</Directory>

# Protege o /usr/share, permitindo acesso somente ao necessário
<Directory /usr/share>
	Options None
	AllowOverride None
	Require all denied
</Directory>

# Libera acesso apenas ao diretório específico onde estão os arquivos públicos
<Directory /var/www/>
	Options -Indexes +FollowSymLinks
	AllowOverride All
	Require all granted
</Directory>

# Adicionar proteção contra execução de scripts fora do diretório web
<FilesMatch "\.(htaccess|htpasswd|ini|phps|fla|psd|log|sh)$">
  Require all denied
</FilesMatch>

# Bloquear acesso a wp-config.php
<Files wp-config.php>
  Require all denied
</Files>

# Bloquear acesso a arquivos .ht*
<FilesMatch "^\.ht">
  Require all denied
</FilesMatch>

# Bloquear execução de PHP em uploads
<Directory "/wp-content/uploads/">
  <FilesMatch "\.php$">
    Require all denied
  </FilesMatch>
</Directory>

# Bloquear XML-RPC (se não usar Jetpack ou apps móveis)
<Files xmlrpc.php>
  Require all denied
</Files>

On the root of the WordPress directory, create the ‘.htaccess’ file with 775 permission

# INÍCIO DAS REGRAS DO WORDPRESS

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
RewriteBase /
RewriteRule ^index\.php$ - [L]

# Qualquer requisição que não seja para um arquivo ou diretório existente
# será redirecionada para index.php, onde o WP decide o que fazer
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>

# FIM DAS REGRAS DO WORDPRESS

Setting the file owner and access permission for all files

sudo chown -R www-data:www-data wp-admin/
sudo chown -R www-data:www-data wp-includes/
sudo chown -R www-data:www-data wp-content/
sudo chown -R www-data:www-data *.php
sudo chown -R www-data:www-data *.html
sudo chown -R www-data:www-data *.txt
sudo chown -R www-data:www-data .htaccess

sudo find . -type d -exec chmod 755 {} \;
sudo find . -type f -exec chmod 644 {} \;

sudo chmod 600 wp-config.php
sudo chmod 775 .htaccess

Alternate and save between ‘Plain’ and ‘Post name’ options

Check if your page is working again. Don’t forget to share with us your solution. I hope I could help you with this. See ya!

Leave a comment