I have 2 LAMP servers with the same version of Apache, both running Wordpress. SSL is working on both servers (although the test server uses a cert for a different domain).

On both I have the following .htaccess file (/var/www/html/.htaccess):

# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On

RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [R,L]

RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]

# END WordPress

The test server redirects to HTTPS correctly, but the production server does not attempt to redirect at all. I can manually browse the production site via HTTPS.

The permissions on the .htaccess file is 755 and owned by apache:apache on both server.

In order to make sure that the redirect on the test site was because of the .htaccess file, I changed it by removing the following:

RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [R,L]

The redirect on on the test site stopped until I added it back.

Is there something that may have been done on the test site that needs to be done on production?

  • Did you checked that mod_rewrite in enabled on production server? – Scyld de Fraud Aug 19 '14 at 17:14
  • Yes, both servers have LoadModule rewrite_module modules/mod_rewrite.so in the /etc/httpd/conf/httpd.conf file. – OrangeGrover Aug 19 '14 at 17:19

I found the issue so I guess I jumped the gun on posting this question, but I'll leave it here - maybe it will save somebody some time.

In the /etc/httpd/conf/httpd.conf file, I had AllowOverride set to None still on the production site for the document root directory.
Here is what it looks like now (with the redirect working):

<Directory "/var/www/html">

# Possible values for the Options directive are "None", "All",
# or any combination of:
#   Indexes Includes FollowSymLinks SymLinksifOwnerMatch ExecCGI MultiViews
# Note that "MultiViews" must be named *explicitly* --- "Options All"
# doesn't give it to you.
# The Options directive is both complicated and important.  Please see
# http://httpd.apache.org/docs/2.2/mod/core.html#options
# for more information.
    Options Indexes FollowSymLinks

# AllowOverride controls what directives may be placed in .htaccess files.
# It can be "All", "None", or any combination of the keywords:
#   Options FileInfo AuthConfig Limit
    AllowOverride All

# Controls who can get stuff from this server.
    Order allow,deny
    Allow from all


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.