1

It seems that the .htaccess file for one of my virtual hosts is being ignored on my production server. The file is identical to working .htaccess files for other vhosts on the same server. Also, the vhost definition is identical to other working vhosts, except, of course, for lines that are specific to the respective vhosts. When the problem is occurring, index.php loads correctly for the base URL, but all rewrite directives are ignored. Also, putting garbage in .htaccess doesn't cause an error.

The site runs as expected on my backup server, to which websites and Apache config files (with one exception, mods-enabled) are mirrored hourly, and to which databases are replicated.

I compared mods-enabled on my backup and production servers, and found that mod_cgid was not enabled in production. Enabling it seemed to fix the problem, but only temporarily.

Selectively deleting rewrites from .htaccess brings no success. I'm considering rebuilding my production server. What other troubleshooting is recommended? Are there any known fixes?

5
  • I moved the redirects from .htaccess to the VirtualHost definition, and the problem is now partially solved. The redirect from http to https now works. Redirecting requests for non-existent files and folders to index.php continues to fail.
    – dcorsello
    Commented Dec 14, 2021 at 15:19
  • It occurs to me that this is the only website I host with a hyphen in the domain name. I tried the fix recommended at the following link with no success: forums.modx.com/thread/70073/…
    – dcorsello
    Commented Dec 14, 2021 at 19:34
  • After hours of troubleshooting, it turned out to be a simple, stupid error in the vhost configuration. Very glad that I didn't rebuild the server. Is it cool to just delete this question?
    – dcorsello
    Commented Dec 15, 2021 at 6:17
  • 1
    I'd say it's fine to delete this question. Having said that, self-answered questions are often useful to others. If you edited the question title to something like .htaccess being ignored by Apache and removed the irrelevant information about the Ubuntu upgrade and mod_cgid from the question body, it could be helpful to someone else who has a similar typo (we all have typos at some stage). It's your call. Commented Dec 15, 2021 at 22:11
  • 1
    @AnthonyGeoghegan, I modified per your suggestions.
    – dcorsello
    Commented Dec 21, 2021 at 1:50

1 Answer 1

2

The problem was caused by a misconfiguration in the VirtualHost definition on my production server. The directory-path was misspelled in the Directory section in which AllowOverride was specified. This is why index.php loaded correctly for the base URL while rewrites were ignored.

Although it appeared that enabling mod-cgid and rebooting the server temporarily fixed the problem, I must have been mistaken. In the course of troubleshooting, I juggled DNS settings to sometimes point the domain to my backup server, and I might have neglected to repoint to the production server. Or I might have neglected to delete browser cache. I can't retrace those steps, and I'm satisfied that things are working now in production.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .