среда, 27 мая 2015 г.

WordPress rewrite apache2 virtualhost

Не работали ЧПУ в WordPress, хотя и были активированы через админку. При попытке открыть статью, получал ошибку 404. Лечится так:

# sudo cat /etc/apache2/sites-enabled/testing04.conf

<VirtualHost *:80>
ServerName testing04.real.local
ServerAdmin webmaster@testing01
DocumentRoot /var/www/testing04/data

<Directory /var/www/testing04/data/>
    Options Indexes FollowSymLinks
    AllowOverride All
    Require all granted
</Directory>

ErrorLog /var/www/testing04/log/error.log
CustomLog /var/www/testing04/log/access.log combined
</VirtualHost>


# sudo a2enmod rewrite
# sudo service apache2 restart

# cat /var/www/testing04/data/.htaccess 

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