2 of 11 added 1540 characters in body

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 olddomain.com to newdomain.com. The structure of the app at the newdomain.com is different than on the olddomain.com, so all requests from the olddomain.com/anyurl need to be redirected to the root url newdomain.com.

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

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

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

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

# 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 ^(.*)$ http://greenriverit.com [R=301,L]

# systemctl restart httpd

Then the test user types olddomain.com/testbadlink 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.

The complete text of httpd.conf is:

ServerRoot "/etc/httpd"
Listen 80
Include conf.modules.d/*.conf
User apache
Group apache
ServerAdmin root@localhost

<Directory />
    AllowOverride none
    Require all denied
</Directory>

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

<IfModule dir_module>
    DirectoryIndex index.html
</IfModule>

<Files ".ht*">
    Require all denied
</Files>

ErrorLog "logs/error_log"
LogLevel warn

<IfModule log_config_module>
    LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" combined
    LogFormat "%h %l %u %t \"%r\" %>s %b" common

    <IfModule logio_module>
      LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\" %I %O" combinedio
    </IfModule>

    CustomLog "logs/access_log" combined
</IfModule>

<IfModule alias_module>
    ScriptAlias /cgi-bin/ "/var/www/cgi-bin/"
</IfModule>

<IfModule mime_module>
    TypesConfig /etc/mime.types
    AddType application/x-compress .Z
    AddType application/x-gzip .gz .tgz
    AddType text/html .shtml
    AddOutputFilter INCLUDES .shtml
</IfModule>

AddDefaultCharset UTF-8

<IfModule mime_magic_module>
    MIMEMagicFile conf/magic
</IfModule>

EnableSendfile on
IncludeOptional conf.d/*.conf