How to enable htaccess in apache?

When I migrated my website from CentOS 6 to CentOS 7, I found the wordpress site stopped working. Only the homepage can be displayed, other internal pages of the website “are not found”. Even the homepage is not displayed properly because it refers to many internal style files which cannot be found.

I know this is due to the .htaccess file of wordpress. Despite the fact the .htaccess file exists in the root directory, it is not working now. It used to work on CentOS6. Why does not .htaccess file work on CentOS 7? That is because the apache on CentOS 7 changes its default configuration in which the .htaccess is disabled.

You should change the apache configuration file:/etc/httpd/conf/httpd.conf to enable .htaccess:

Change

to

 

Now all websites put in /var/www enable their .htaccess files.

reference:https://phoenixnap.com/kb/how-to-set-up-enable-htaccess-apache

Posted in tips of hosting