User made .htaccess files don't run as intended

Hi,
I seem to have an issue with getting any websites with custom written .htaccess files to run successfully on my local machine. Attempting to run them always results in a 500 Server Error.

Upon further inspection on the log file (/var/log/httpd/error_log), I came across the error message that says:

.htaccess: Options not allowed here

Which does not make sense as I explicitly allowed Options in my httpd.conf file. Is there another file I’m supposed to modify to allow my custom written .htaccess files to work?

Here is what my httpd.conf config looks like:

DocumentRoot "/home/cyb3rtooth/public_html"
<Directory "/home/cyb3rtooth/public_html">
    Options Indexes FollowSymLinks MultiViews
    AllowOverride Authconfig FileInfo Options
    Require all granted
</Directory>

<Directory "/srv/http/cgi-bin">
    AllowOverride All 
    Options None
    Require all granted
</Directory>

Believe me, I tried changing AllowOverride to All as well with still no results. I am confused.

In case you were wondering, this is what my custom written .htaccess files look like:
File in main directory:

<IfModule mod_rewrite.c>
	RewriteEngine On
	RewriteRule ^$ public/ [L]
	RewriteRule (.*) public/$1 [L]
</IfModule>

File in public directory:

<IfModule mod_rewrite.c>
	Options -Multiviews
	RewriteEngine On
	RewriteBase /blog/public
	RewriteCond %{REQUEST_FILENAME} !-d
	RewriteCond %{REQUEST_FILENAME} !-f
	RewriteRule ^(.+)$ index.php?url=$1 [QSA,L]
</IfModule>

File in app directory:

Options -Indexes

Any help would be highly appreciated.

You set a directory in a user home directory. With which user:group do ‘apache’ run and does this user:group rights to access your users homes?

… for apache my knowledge is very low … perhaps someone else got an idea… :laughing:

Yes. the user group has rights to access the directory and apache has access to run from this directory as well. I am not getting a forbidden error. Because all other websites I am hosting locally WITHOUT any .htaccess files run perfectly. The issue is when I use .htaccess files, that’s when they result to a 500 server Error.

The error_log file says the issue is : .htaccess: Options not allowed here

I managed to solve the issue by editing the: /etc/httpd/conf/extra/httpd-userdir.conf file:
Changed:
AllowOverride Option1 Option2 Option3 to:
AllowOverride All

Note to other devs using .htaccess rules:
Make sure you are using
AllowOverride All in both your /etc/httpd/conf/httpd.conf file and your /etc/httpd/conf/extra/httpd-userdir.conf files.

There are still other files in ‘/etc/httpd/conf/extra/’. For example ‘httpd-userdir.conf’. Perhaps one …

… you are faster then me! :laughing:

1 Like

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.