SOLVED Error 500 - public_html/.htaccess: <Directory not allowed here

Operating System & Version
Centos 7
cPanel & WHM Version
104.0.10

HaNi Ghaith

Member
Feb 21, 2020
18
2
3
Palestine
cPanel Access Level
Root Administrator
Hello,

I have transferred from VPS to a Dedicated server.
After the transfer, all sites work perfectly, but one of these sites shows a 404 error and solves it by modifying the writing rules and adding.


RewriteBase /
<Directory /var/www/>
AllowOverride All
</Directory>


I did this already but it shows a 500 Internal Server Error.

When reading the log, I see the following error:
[core:alert] [pid 6627:tid 47924754315008] [client IP:42113] /home/User/public_html/.htaccess: <Directory not allowed here

I searched and tried more than one option and the fix didn't work.

any suggestions?
 

cPRex

Jurassic Moderator
Staff member
Oct 19, 2014
16,597
2,615
363
cPanel Access Level
Root Administrator
Hey there! This error is telling you that you can't use the "Directory" command inside the .htaccess file, so you'll need to remove that code. cPanel also includes the "AllowOverride All" code in the main Apache configuration file, so I wouldn't expect that you need to add that manually to an individual domain.

You can add the code you need to the .htaccess file without the Directory tags, as .htaccess is limited to the directory it exists in already.
 

HaNi Ghaith

Member
Feb 21, 2020
18
2
3
Palestine
cPanel Access Level
Root Administrator
Thank you for your answer.

I have already tried removing it
These are the contents of the .htaccess file now:

But this did not fix the problem


Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all


# php -- BEGIN cPanel-generated handler, do not edit
# Set the “ea-php74” package as the default “PHP” programming language.
<IfModule mime_module>
AddHandler application/x-httpd-ea-php74 .php .php7 .phtml
</IfModule>
# php -- END cPanel-generated handler, do not edit
 

HaNi Ghaith

Member
Feb 21, 2020
18
2
3
Palestine
cPanel Access Level
Root Administrator
I tried to read logs after removing the write rules from the .htaccess file but I don't see any errors except the 404 error that appears on the site.

Any suggestions on what to do to determine the cause of this error?

I migrated to this server recently and I suspect this has something to do with this issue.
So what is the setting in Apache that might cause this kind of problem in your opinion?
 

HaNi Ghaith

Member
Feb 21, 2020
18
2
3
Palestine
cPanel Access Level
Root Administrator
Are there any Apache models that have something to do with this problem? Anyway, I built Apache a few days ago and all the sites are working except for this site that I later transferred to the server.
 

HaNi Ghaith

Member
Feb 21, 2020
18
2
3
Palestine
cPanel Access Level
Root Administrator
This is exactly what I did, but I see errors related to another user that has nothing to do with the site that contains the problem.
No logs related to error 404 appear.

directive --- ignoring!
[Mon Sep 12 16:57:46.034597 2022] [core:notice] [pid 29279:tid 47309371021056] AH00113: /home/user/public_html/forum/.htaccess:13 cannot use a full URL in a 401 ErrorDocument directive --- ignoring!
[Mon Sep 12 16:57:46.449621 2022] [core:notice] [pid 29768:tid 47309366818560] AH00113: /home/user/public_html/.htaccess:37 cannot use a full URL in a 401 ErrorDocument directive --- ignoring!
[Mon Sep 12 16:57:46.449673 2022] [core:notice] [pid 29768:tid 47309366818560] AH00113: /home/user/public_html/forum/.htaccess:13 cannot use a full URL in a 401 ErrorDocument directive --- ignoring!