3

I have a .htaccess file in /var/www/html/htc directory with specific rules to bookmatic.net and another .htaccess file with general rules to all domains in /var/www/html

When accesing bookmatic.net, the .htaccess file in /htc is running good, but the one in /html is being ignored. Can anyone help?

bookmatic.net specs in httpd.conf are like this:

<VirtualHost *:443>
    ServerName bookmatic.net
    ServerAlias *.bookmatic.net
    DocumentRoot /var/www/html/htc
    AllowEncodedSlashes On

    <Directory /var/www/html/htc>
        Options Indexes FollowSymLinks MultiViews
        AllowOverride All
        Require all granted
        LimitRequestBody 25000000
        LimitXMLRequestBody 25000000
    </Directory>

    RewriteEngine on
</VirtualHost>
1
  • Please include the contents of your .htaccess files in your question. (From comments below it sounds like you may have a conflict or directives that are incompatible in the context they are being used?) Also, why are you enabling the RewriteEngine in the vHost, you don't appear to have any mod_rewrite directives here? And why are you enabling MultiViews?
    – MrWhite
    Dec 27, 2020 at 16:31

2 Answers 2

2

AllowOverride All is the directive that tells Apache to look in .htaccess files for more configuration.

That vhost tells Apache to look for .htaccess files in /var/www/html/htc and deeper so it doesn't cover the .htaccess file in /var/www/html.

One way to solve this would be to create another block like this (possibly in httpd.conf rather than this vhost if that makes more sense):

<Directory /var/www/html>
     AllowOverride All
</Directory>
4
  • I actually tryed it before posting the question; tryed once again (I'm keeping all blokc in this vhost for tests not to mess with working domains): ServerName bookmatic.net ServerAlias *.bookmatic.net DocumentRoot /var/www/html/htc AllowEncodedSlashes On <Directory /var/www/html/htc> Options Indexes FollowSymLinks MultiViews AllowOverride All Require all granted LimitRequestBody 25000000 LimitXMLRequestBody 25000000 </Directory> <Directory /var/www/html> AllowOverride All </Directory> RESULT = Error 500 Dec 26, 2020 at 23:24
  • 1
    That sounds like it worked but there's something in the other .htaccess file that is causing the 500 response. There will likely be something in your error logs about it or you could find the offending line by commenting them out one by one.
    – Ladadadada
    Dec 27, 2020 at 0:32
  • I don't believe this would be the error 500 cause, as the other htacces is serving all other domains in my server and they're all working properly. Actually, if I remove /htcin DocumentRoot /var/www/html/htcand <Directory /var/www/html/htc>, all works well too Dec 27, 2020 at 9:33
  • @DiegoFlores You should edit your question to include this additional information (avoid including code dumps in unformatted comments). Your error log will have more details regarding the 500 response.
    – MrWhite
    Dec 27, 2020 at 16:35
2

You have AllowOverride All for <Directory /var/www/html/htc>. I suppose it's not allowed in /var/www/html. You could try:

<Directory /var/www/html>
    AllowOverride All
</Directory>
1
  • I actually tryed it before posting but tryed once again (I'm keeping all block in this vhost for tests not mess working domains) [sorry I cant get comments to format code]: ServerName bookmatic.net ServerAlias *.bookmatic.net DocumentRoot /var/www/html/htc AllowEncodedSlashes On <Directory /var/www/html/htc> Options Indexes FollowSymLinks MultiViews AllowOverride All Require all granted LimitRequestBody 25000000 LimitXMLRequestBody 25000000 </Directory> <Directory /var/www/html> AllowOverride All </Directory> RESULT = Error 500 Dec 26, 2020 at 23:30

You must log in to answer this question.

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