The Stack Overflow podcast is back! Listen to an interview with our new CEO.
1 of 11

why isn't .htaccess redirecting requests on CentOS 7?

A web app running on CentOS 7 with Apache 2.4 recently changed its domain name from to The structure of the app at the is different than on the, so all requests from the need to be redirected to the root url

A new .htaccess file was created, and httpd was restarted, so why do requests for fail to redirect to Instead, the user just gets a 404 error at

Here are the steps that were taken at the command line:

# nano /etc/httpd/conf/httpd.conf

    <Directory "/var/www/html">
        AllowOverride All

# sudo systemctl restart httpd
# cd /var/www/html

# nano /var/www/html/.htaccess

    Options +FollowSymLinks
    RewriteEngine On
    RewriteBase /
    RewriteCond %{HTTP_HOST} !^healthprocesspartners\.com$ [NC]
    RewriteRule ^(.*)$ [R=301,L]

# systemctl restart httpd

Then the test user types in the web browser. The logs at nano /var/log/httpd/olddomain_com_requests.log show a 404 error, but there are NO LOGS at nano /var/log/httpd/olddomain_com_error.log.

In case it was a permissions error, root typed chown apache:apache /var/www/html/.htaccess, but the same problem is persisting.

Is this an SELinux problem? Or is the syntax of the .htaccess file incorrect? Is there some other possible cause?

This is the first time that .htaccess has been used on this specific server, so there are no previous working conditions for .htaccess to which to refer on this server.