Tran Nghi's Site  - Make notes and share experience

Xử lý một số lỗi WordPress

This post is also available in: English

1) Trắng trang, không truy cập được wp-admin sau khi chuyển hosting…

Chưa biết làm gì, thì bật liền chế độ debug lên xem: wp-config.php

define(‘WP_DEBUG’, true);

2) Lỗi về RewriteEngine trên Linux (Ubuntu 16.10 LTS):

2.1 Enabling mod_rewrite

First, we need to activate mod_rewrite. It’s available but not enabled with a clean Apache 2 installation.

sudo a2enmod rewrite

This will activate the module or alert you that the module is already enabled. To put these changes into effect, restart Apache.

sudo systemctl restart apache2

mod_rewrite is now fully enabled. In the next step we will set up an .htaccess file that we’ll use to define rewrite rules for redirects.

2.2 Setting Up .htaccess

An .htaccess file allows us to modify our rewrite rules without accessing server configuration files. For this reason, .htaccess is critical to your web application’s security. The period that precedes the filename ensures that the file is hidden.

Note: Any rules that you can put in an .htaccess file can be also put directly into server configuration files. In fact, the official Apache documentation recommends using server configuration files instead of .htaccess because Apache processes it faster that way.

However, in this simple example, the performance increase will be negligible. Additionally, setting rules in .htaccess is convenient, especially with multiple websites on the same server. It does not require a server restart for changes to take effect and it does not require root privileges to edit those rules, simplifying maintenance and and making changes possible with unprivileged account. Some popular open-source software, like WordPress and Joomla, often relies on an .htaccess file for the software to modify and create additional rules on demand.

We will need to set up and secure a few more settings before we can begin.

By default, Apache prohibits using an .htaccess file to apply rewrite rules, so first you need to allow changes to the file. Open the default Apache configuration file using nano or your favorite text editor.

sudo nano /etc/apache2/sites-available/000-default.conf
Inside that file, you will find a <VirtualHost *:80> block starting on the first line. Inside of that block, add the following new block so your configuration file looks like the following. Make sure that all blocks are properly indented.

/etc/apache2/sites-available/000-default.conf
<VirtualHost *:80>
<Directory /var/www/html>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Require all granted
</Directory>

. . .
</VirtualHost

Save and close the file. To put these changes into effect, restart Apache.

sudo systemctl restart apache2

Now, create the .htaccess file in the web root.

sudo nano /var/www/html/.htaccess

Add this line at the top of the new file to activate the rewrite engine.

/var/www/html/.htaccess

RewriteEngine on

Source: https://www.digitalocean.com/community/tutorials/how-to-rewrite-urls-with-mod_rewrite-for-apache-on-ubuntu-16-04

 

Message