Wordpress永久链接不适用于新服务器

My server was recently compromised. I moved everything to a new server, but for some reason the permalinks for the Wordpress site are not working properly. I've looked everything over and it all appears to be correct, but I can't see why the links won't work when the settings were all copied over from the old server where they all worked.

Server .conf:

<VirtualHost *:80>    
ServerName www.XXX.com
ServerAdmin webmaster@localhost
DocumentRoot /var/www/html/XXX.com/

ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined

# For most configuration files from conf-available/, which are
# enabled or disabled at a global level, it is possible to
# include a line for only one particular virtual host. For example the
# following line enables the CGI configuration for this host only
# after it has been globally disabled with "a2disconf".
#Include conf-available/serve-cgi-bin.conf
</VirtualHost>

<VirtualHost *:80>
ServerAlias XXX.com
ServerAdmin XXX
DocumentRoot /var/www/html/XXX.com/
ServerName www.XXX.com
DirectoryIndex index.html index.php
<Directory "/var/www/html/www.XXX.com/">
    allow from all
    Options -Indexes
    AllowOverride All
</Directory>
CustomLog ${APACHELOGDIR}/XXX.log common
ErrorLog ${APACHELOGDIR}/XXX-error.log

</VirtualHost>

.htaccess:

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index.php$ - [L]
RewriteCond %{REQUESTFILENAME} !-f
RewriteCond %{REQUESTFILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>

Make sure .htaccess has right permissions so that wordpress can change it on its own.