Server unable to read htaccess file

New Page

.htaccess not working – How to Troubleshoot and Fix

Updated March 14, 2020

.htaccess not working - How to Troubleshoot and Fix

Contents

  • .htaccess Common issues
    • .htaccess must be enabled with AllowOverride
    • The file name is misspelled or does not start with a period
    • Placement of your rulers should be above or below others
    • Conflicting .htaccess files
    • Incorrect syntax is used
  • How to troubleshoot .htaccess not working
    • Use an .htaccess validator
    • Apache Error Log Check
    • Debugging with the Apache configuration file
    • Debug mod_rewrite with logs
  • abstract

El archivo de acceso de hipertexto, o más conocido como .htaccess, es un archivo de configuración para servidores web Apache que se puede usar para definir opciones de configuración muy específicas . Las configuraciones pueden volverse bastante granulares con el uso de expresiones regulares ; sin embargo, la mayoría de los usuarios suelen ceñirse al uso de ejemplos populares.htaccess , como la redirección de páginas web o la configuración de encabezados personalizados.

Aunque .htaccesspuede ser bastante útil, también puede ser un desafío averiguar dónde está el problema dado que .htaccessno funciona. Esta publicación proporciona algunos consejos para ayudar a resolver este problema al identificar algunos .htaccessproblemas comunes que puede verificar en su propio .htaccessarchivo, así como algunas técnicas de solución de problemas.

.htaccessProblemas comunes #

A continuación se incluyen algunos .htaccessproblemas comunes que son fáciles de solucionar y que vale la pena intentar si tiene problemas con su .htaccessarchivo que no funciona.

.htaccessnecesita ser habilitado con AllowOverride #

This is the first thing to check. If the AllowOverride directive is set to None, it will disable all .htaccess files. To verify this, you need to open the Apache configuration file (usually named httpd.conf or apache.conf) and verify that the AllowOverride directive is set to AllowOverride All. If you need to make changes to your Apache configuration, remember to save the file and restart Apache .

sudo apache2 service restart

The file name is misspelled or does not start with a dot #

Si está creando un .htaccessarchivo desde cero (es decir, no está utilizando un CMS que viene con un .htaccessarchivo incluido), debe asegurarse de que el nombre del archivo sea correcto y que comience con un punto ( .). Sin el punto al principio, Apache ignorará el archivo; lo mismo ocurre si el archivo está mal escrito. Además, verifique que el nombre del archivo esté en minúsculas . Su .htaccessarchivo debe llamarse exactamente como .htaccess.

La ubicación de sus reglas debe estar por encima o por debajo de otras #

Ciertas .htaccessreglas pueden ser sensibles a su ubicación dentro del .htaccessarchivo y, por lo tanto, causar un .htaccessproblema de no funcionamiento. Si al agregar una .htaccessregla nota que no tiene efecto, intente moverla encima de la regla anterior o al principio de su archivo.

.htaccessArchivos en conflicto #

Aunque la mayoría de los usuarios simplemente usan un .htaccessarchivo, usted tiene la posibilidad de usar varios. Dado .htaccessque las reglas de archivo se aplican al directorio en el que viven, así como a todos los demás subdirectorios, puede suceder que dos o más .htaccessarchivos entren en conflicto entre sí. Para verificar esto, intente deshabilitar cada .htaccessarchivo adicional que tenga uno por uno para ver dónde está el problema.

Se está utilizando una sintaxis incorrecta #

Es bastante común que un error de sintaxis sea la razón por la que un .htaccessarchivo no funciona. Si está familiarizado con la lectura y configuración .htaccessde reglas, vuelva a verificar su configuración. De lo contrario, puede utilizar los consejos de solución de problemas que se mencionan en la siguiente sección para ayudar a determinar por qué está experimentando un problema.

Cómo solucionar problemas que .htaccessno funcionan #

Hay algunas opciones disponibles para solucionar problemas y .htaccessno funciona. Dependiendo del tipo de problema que intente resolver, es posible que deba usar una combinación de las sugerencias que se mencionan a continuación para determinar qué pasos se deben tomar para corregir el problema.

Usando un .htaccessvalidador #

Si tiene problemas con la sintaxis real de su .htaccessarchivo, puede ejecutar su contenido a través de un .htaccessvalidador. Las siguientes herramientas verificarán su sintaxis e informarán cualquier error que encuentren.

  • .htaccess Check : esta primera herramienta le brinda dos opciones para validar su .htaccessarchivo. Puede copiar y pegar el contenido de su archivo directamente en la herramienta o cargar un .htaccessarchivo. Luego, la herramienta verificará su sintaxis y resaltará las líneas en las que encuentre errores . htaccess checker tool
  • Lyxx : también puede utilizar el .htaccessvalidador de sintaxis que ofrece Lyxx. Esta herramienta es similar a la mencionada anteriormente, excepto que no tiene la opción de cargar un .htaccessarchivo, solo puede copiar y pegar su sintaxis. lyxx htaccess validation tool

Comprobando el registro de errores de Apache #

If changes to your .htaccess file cause your website to crash, you can also check the Apache error log for additional debugging information. The Apache error log file is usually located in the /var/log/apache2/ directory. So let’s say for example we have the following content in our .htaccess file.

# BEGIN WordPress <IfModule mod_rewrite.c> RewriteEngine On RewriteBase / RewriteRule ^index\.php$ -[L] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule . /index.php [L] </IfModule> # END WordPress This is gibberish

As you can see, I added “That’s gibberish” to intentionally throw an error. Once this file is saved and the page reloads, we can check the error logs with the following command.

sudo tail /var/log/apache2/error.log

In this case, Apache returns the following error:

/var/www/wordpress/.htaccess: invalid command ‘This’, possibly missed or defined by a module not included in the server configuration, referrer: http://yourwebsite.com/

We may use this information to later return to our .htaccess file and delete or modify any part of the file reported in the error log.

Debugging with Apache config file #

Lastly, you can also debug the content of your .htaccess file by inserting it into your Apache configuration file instead. All of the .htaccess rules will still apply in your configuration file, however now Apache will parse and check the configuration file. Be sure to include all the contents of your .htaccess in the <Directory> directive. Using the same example as above, the <Directory> portion of your config file may look similar to the following.

<Directory /var/www/wordpress> Options Indexes FollowSymLinks MultiViews AllowOverride All Order allow,deny allow from all # BEGIN WordPress <IfModule mod_rewrite.c> RewriteEngine On RewriteBase / RewriteRule ^index\.php$ – [L] RewriteCond %{REQUEST_FILENAME } !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule . /index.php [L] </IfModule> # END WordPress This is gibberish </Directory>

Once saved, you can run the following command to check the syntax of your configuration file.

sudo apache2ctl -t

In this case, Apache returns an error message stating that there is a syntax error on line 72 of my configuration file. If you use this method, you may also want to check the error logs in case additional information was logged there.

Debugging mod_rewrite with logs #

If you are using the Apache mod_rewrite module, you can also enable the rewrite log to provide you with more debugging details. To do this, you need to have access to your Apache web server configuration file . Start by opening the configuration file and adding the appropriate directive values ​​as needed. For instance:

Rewrote LogLevel alert: trace6

L’extrait ci-dessus enregistrera toutes les erreurs mod_rewrite jusqu’au niveau “alerte” dans votre fichier error.log. Consultez la directive de niveau de journalisation d’Apache pour en savoir plus. Il convient de noter que plus le niveau de journal de suivi que vous définissez est élevé, plus cela ralentira votre serveur Web Apache.

Sommaire#

.htaccess files are extremely useful in many cases for users who either do not have root permissions or for users who simply aren’t comfortable in making changes in their web server’s configuration file. Trying to debug .htaccess not working isn’t always the easiest thing to do, however, hopefully by checking the above mentioned .htaccess common problems as well as the troubleshooting tips, you’ll have a better grasp on what you may have to modify to get your .htaccess file running smoothly.

Additionally, if you would like to do some further testing, give the htaccess tester tool a try. It allows you to specify a certain URL as well as the rules you would like to include and then shows which rules were tested, which ones met the criteria, and which ones were executed.

Server unable to read htaccess file, denying access to be safe

Ask Question

Asked 7 years, 2 months ago

Modified 1 year, 7 months ago

Viewed 337k times

Report this ad

This question shows research effort; it is useful and clear

105

This question does not show any research effort; it is unclear or not useful

23

Bookmark this question.

Show activity on this post.

I have created a simple app using AngularJS. When I tried to host that project in my website http://demo.gaurabdahal.com/recipefinder it shows the following error:

Forbidden

You don’t have permission to access /recipefinder on this server. Server unable to read htaccess file, denying access to be safe

Mais si je vais sur http://demo.gaurabdahal.com/, le message “accès refusé” s’affiche comme prévu, que j’ai imprimé. Mais pourquoi est-il incapable d’ouvrir ce projet AngularJS “recipefinder”. Si j’essayais d’y mettre une simple application HTML, elle s’ouvrirait très bien.

Le même projet AngularJS fonctionne bien lorsque je l’héberge dans github (http://gaurabdahal.github.io/recipefinder)

Je ne peux pas comprendre ce qui ne va pas.

  • .htaccess

Compartir

Partager un lien vers cette question

Copier le lien CC BY-SA 4.0

Améliorer cette question

Suivre

Suivez cette question pour recevoir des notifications

modifié le 2 septembre 2020 à 13:54

yivi user avatar

Yivi

37.5k 18 18 insignes d’or 93 93 insignes d’argent 119 119 insignes de bronze

demandé le 12 juillet 2015 à 8:42

Saurab user avatar

Saurab Saurab

1,781 4 4 gold badges 17 17 silver badges 33 33 bronze badges

4

  • 1

    possible duplicate new Magento host – 403 Forbidden – Server unable to read htaccess file

    – 200_success

    Jul 12, 2015 at 8:46 am

  • Even if I set the file permission to 777 , it doesn’t work.

    – Saurab

    Jul 12, 2015 @ 8:58 AM

  • 142

    Every time you chmod 777, somewhere in the world a kitten dies

    -Janus

    Jul 12, 2015 at 6:10 PM

  • 1

    If it worked before and it happens out of the blue, try restarting apache first. No more death kittens.

    – sglessard

    Jan 18, 2017 at 9:33 PM

Add a comment | 

15 answers 15

Sorted by: Reset to default

Highest score (default) Trending (recent votes count more) Date modified (newest first) Date created (oldest first)

This answer is helpful

220

This answer is not helpful

View activity on this post.

I had this problem too. My advice is to look in your server’s error log file. For me it was that the top directory of the project was not readable. The error log clearly indicated this. single

sudo chmod 755 <site_top_folder>

fixed it for me.

compare

Share a link to this answer

Copy link CC BY-SA 4.0

Improve this answer

Follow

Follow this answer to receive notifications

modified on September 2, 2020 at 10:12

Black user avatar

Black

16.2k 35 35 gold badges 145 145 silver badges 246 246 bronze badges

answered on February 22, 2017 at 3:56 PM

swedge218 user avatar

swedge218 swedge218

3,093 1 1 gold badge 13 13 silver badges 12 12 bronze badges

3

  • This is because your system folder path doesn’t seem to be set correctly. Please open the following file and correct it: index.php

    – user3787990

    November 21, 2018 at 5:07 am

  • 16

    In my case the top directory was set to 750 (not sure why), change it to 755 and it worked

    -Paul

    Jul 5, 2019 @ 3:35 PM

  • This <site_top_folder> is the most important. You must authorize the ROOT folder. It worked well. Thanks.

    – Chaminda Bandara

    December 14, 2019 at 5:24 PM

Add a comment | 

Report this ad

This answer is helpful

30

This answer is not helpful

View activity on this post.

Set the group in your public directory to nobody.

compare

Share a link to this answer

Copy link CC BY-SA 3.0

Improve this answer

Follow

Follow this answer to receive notifications

answeredJan 6, 2016 at 8:45 am

Mycelin user avatar

Mycelin Mycelin

587 7 7 silver badges 6 6 bronze badges

1

  • 1

    That was the problem I had. Thanks.

    – Art Gegel

    April 14, 2021 at 7:59 am

Add a comment | 

This answer is helpful

26

This answer is not helpful

View activity on this post.

This is a common problem with GoDaddy virtual server hosting when you open a new website.

En supposant que vous ayez un accès SSH au serveur (vous devez l’activer sur cPanel), connectez-vous à votre compte. Une fois la connexion réussie, vous serez placé dans le répertoire d’accueil de votre compte. Le DocumentRoot de votre site Web se trouve dans un sous-répertoire nommé public_html. GoDaddy définit par défaut les autorisations pour ce répertoire sur 750, mais ces autorisations sont insuffisantes pour permettre à Apache de lire les fichiers du site Web. Vous devez changer les permissions pour ce répertoire en 755 (chmod 755 public_html).

Copiez les fichiers de votre site Web dans le répertoire public_html (scp et rsync fonctionnent pour copier des fichiers sur un serveur GoDaddy Linux).

Ensuite, assurez-vous que tous les fichiers sous public_html sont lisibles par tous. Pour ce faire, utilisez cette commande :

cd public_html chmod -R o+r *

If you have other subdirectories (like css, js, and img), make sure they’re accessible to everyone by enabling both read and execute for universal access:

chmod o+rx css chmod o+rx img chmod o+rx js

Finally, you will need to have an .htaccess file inside the public_html file. GoDaddy enforces a rule that prohibits the site from loading if you don’t have an .htaccess file in your public_html directory. You can use vi to create this file (“vi .htaccess”). Enter the following lines in the file:

Order allow, deny Allow all Require all to be granted

This configuration will work for both Apache 2.2 and Apache 2.4. Save the file (ZZ), then make sure the file has 644 permissions:

chmod 644 .htaccess

Works like a charm.

compare

Share a link to this answer

Copy link CC BY-SA 4.0

Improve this answer

Follow

Follow this answer to receive notifications

modified on February 13, 2019 at 1:27 PM

Avatar of Andras Aszodi

Andras Aszodi

8,063 5 5 gold badges 44 44 silver badges 47 47 bronze badges

answeredJan 15, 2016 at 11:15 PM

David Stoddard user avatar

David StoddardDavid Stoddard

269 ​​3 3 silver badges 5 5 bronze badges

1

  • of them

    of course chmod 644 .htaccess is very important otherwise it won’t work! 🙂

    – to light up

    November 4, 2017 at 10:40 am

Add a comment | 

Report this ad

This answer is helpful

twenty one

This answer is not helpful

View activity on this post.

You should run these commands in /var/www/html/ or whatever directory your project is in:

sudo chgrp -R GROUP ./ sudo chown -R USER:GROUP ./ find ./ -type d -exec chmod 755 -R {} \; find ./ -type f -exec chmod 644 {} \;

In my case (apache web server) I use www-data for USER and GROUP

compare

Share a link to this answer

Copy link CC BY-SA 4.0

Improve this answer

Follow

Follow this answer to receive notifications

modified on November 28, 2020 at 8:42 AM

answered on February 11, 2018 at 9:32

Vahid user avatar

Vahid Vahid

5,792 5 5 gold badges 36 36 silver badges 55 55 bronze badges

1

  • 1

    Why do you use sudo chgrp -R GROUP ./ if you already set the group with sudo chown -R USER:GROUP ./ ? It’s redundant

    -Black

    Sep 24, 2021 at 12:07 PM

Add a comment | 

This answer is helpful

13

This answer is not helpful

View activity on this post.

Each public folder gives permission to 755. Issue resolved.

compare

Share a link to this answer

Copy link CC BY-SA 4.0

Improve this answer

Follow

Follow this answer to receive notifications

answered on November 2, 2019 at 0:35 am

rashedcs user avatar

rashedcs rashedcs

3,327 2 2 gold badges 36 36 silver badges 39 39 bronze badges

0

Add a comment | 

This answer is helpful

ten

This answer is not helpful

View activity on this post.

GoDaddy Shared Server Solution

I had the same problem trying to deploy a separate Laravel project at the subdomain level.

File structure

– public_html (where main web app resides) [works fine] – booking.mydomain.com (folder for separate Laravel project) [displays 403 error prohibited]

The solution

  1. go to cPanel of your GoDaddy account

  2. open file manager

  3. navigate to the folder that shows the 403 forbidden error

  4. in the file manager, right click on the folder (in my case booking.mydomain.com)

  5. select Edit permissions

  6. check the following boxes

    a) user – read, write, execute b) group – read, execute c) world – read, execute Authorization code should display as 755

  7. Click edit permissions

compare

Share a link to this answer

Copy link CC BY-SA 4.0

Improve this answer

Follow

Follow this answer to receive notifications

modified on July 23, 2020 at 6:23 PM

answered on February 4, 2018 at 12:27

Armand user avatar

Armand Armand

2 292 2 2 gold badges 23 23 silver badges 36 36 bronze badges

0

Add a comment | 

This answer is helpful

seven

This answer is not helpful

View activity on this post.

Under linux,

find project_directory_name_here -type d -exec chmod 755 {} \; find project_directory_name_here -type f -exec chmod 644 {} \;

It will override all file and folder permissions of project_directory_name_here and its internals.

compare

Share a link to this answer

Copy link CC BY-SA 4.0

Improve this answer

Follow

Follow this answer to receive notifications

answeredNovember 28, 2020 at 6:54 am

Harat User Avatar

Harat Harat

1 148 1 1 gold badge 14 14 silver badges 18 18 bronze badges

1

  • @alib0ng0… Glad I could help

    – Harat

    Jan 14, 2021 at 2:51 PM

Add a comment | 

This answer is helpful

4

This answer is not helpful

View activity on this post.

Dans mon cas, apache était en quelque sorte mal configuré (?), J’ai donc dû également définir des autorisations pour tous les répertoires parents. Le simple fait de définir l’autorisation sur .htaccess (et son répertoire parent) n’a pas fonctionné.

Compartir

Partager un lien vers cette réponse

Copier le lien CC BY-SA 4.0

Améliorer cette réponse

Suivre

Suivez cette réponse pour recevoir des notifications

édité le 27 juillet 2020 à 6:05

répondu le 28 septembre 2016 à 9:18

MilanG user avatar

MilanG MilanG

6 866 2 2 insignes d’or 33 33 insignes d’argent 61 61 insignes de bronze

Ajouter un commentaire | 

Cette réponse est utile

4

Cette réponse n’est pas utile

Afficher l’activité sur ce post.

Ok, j’ai récemment rencontré le même problème alors que je travaillais sur une installation WordPress utilisant apache2 sur le serveur sous Ubuntu 20.04.

I ran into this problem when I changed ownership of the file to another user:

Here is what worked for me:

$ sudo chown -R www-data:www-data /var/www/YOUR-DIRECTORY

Here’s a bit more context into the problem:

The above command gives ownership of all files [in this folder] to user and group www-data . This is the user under which the Apache web server is running, and Apache will need to be able to read and write WordPress files in order to serve the website and perform automatic updates.

Be sure to point to the relevant directory on your server (replace YOUR-DIRECTORY with your current folder).

You could browse this insightful article on digitalocean.

compare

Share a link to this answer

Copy link CC BY-SA 4.0

Improve this answer

Follow

Follow this answer to receive notifications

modified on February 9, 2021 at 5:53 PM

answered on February 9, 2021 at 5:20 PM

MwamiTovi user avatar

Mwami Tovi Mwami Tovi

2,190 15 15 silver badges 23 23 bronze badges

Add a comment | 

This answer is helpful

3

This answer is not helpful

View activity on this post.

As for Apache running on Ubuntu, the solution was to check the error log, which showed that the error was related to folder and file permission.

First, check Apache’s error log

nano /var/log/apache2/error.log

Then set the folder permission to be executable

sudo chmod 755 /var/www/html/

Also set the file permission to be readable

sudo chmod 644 /var/www/html/.htaccess

compare

Share a link to this answer

Copy link CC BY-SA 4.0

Improve this answer

Follow

Follow this answer to receive notifications

editedSeptember 22, 2019 @ 9:40 PM

answered on September 22, 2019 at 9:32 PM

Lua user avatar

Lua Lua

57 8 8 bronze badges

1

  • Yes, the top directory path should be set as sudo chmod 755 /var/www/html because sometimes the top directory is not set as 755

    –Suraj Bhatt

    Jan 12, 2021 at 6:24 PM

Add a comment | 

This answer is helpful

1

This answer is not helpful

View activity on this post.

Juste ma solution. J’avais extrait un fichier, apporté quelques modifications mineures et obtenu l’erreur ci-dessus. Tout supprimé, téléchargé et extrait à nouveau, et les affaires normales.

Compartir

Partager un lien vers cette réponse

Copier le lien CC BY-SA 4.0

Améliorer cette réponse

Suivre

Suivez cette réponse pour recevoir des notifications

répondu17 février 2019 à 7:03

User avatar of user2060451

utilisateur2060451 utilisateur2060451

2 496 3 3 insignes d’or 22 22 insignes d’argent 31 31 insignes de bronze

Ajouter un commentaire | 

Cette réponse est utile

0

Cette réponse n’est pas utile

Afficher l’activité sur ce post.

Points importants dans mon expérience :

  • every resource accessed by the server must be in an executable and readable directory, hence the xx5 in every chmod in other answers.
  • most of the time the webserver (apache in my case) is running neither as the user nor in the group that owns the directory, so again xx5 or chmod o+rx is necessary.

But the greater conclusion I reached is start from little to more.

For example, if http://myserver.com/sites/all/resources/assets/css/bootstrap.css yields a 403 error, see if http://myserver.com/ works, then sites, then sites/all, then sites/all/resources, and so on.

It will help if your server has directory indexes enable:

  • In Apache: Options +Indexes

This instruction might also be in the .htaccess of your webserver public_html folder.

Share

Share a link to this answer

Copy link CC BY-SA 3.0

Improve this answer

Follow

Suivez cette réponse pour recevoir des notifications

modifié le 30 août 2016 à 22:08

dg99 user avatar

dg99

5 156 2 2 gold badges 36 36 silver badges 49 49 bronze badges

answered on August 30, 2016 at 9:35 PM

Avatar of Juan Javier Triff Cabanas

Juan Javier Triff Cabanas Juan Javier Triff Cabanas

483 7 7 silver badges 14 14 bronze badges

1

  • Since the question has already been asked, I’ll post here that I suddenly get the same error on a system that was working a short time ago. According to the Apache2 error.log, it apparently looks for a .htaccess file in /var/www when there never was. There is one in /var/www/html and others in the site folders. Why a sudden error? I am using Ubuntu 19.10.

    – DonP

    January 11, 2020 at 9:35 am

Add a comment | 

This answer is helpful

0

This answer is not helpful

View activity on this post.

I had the same problem on Fedora and found the problem to be selinux. to test that this is a problem, run the command: sudo setenforce 0

Otherwise or change in the file /etc/sysconfig/selinux

SELINUX=application to SELINUX=disabled

or add rules to selinux to allow http access

compare

Share a link to this answer

Copy link CC BY-SA 4.0

Improve this answer

Follow

Follow this answer to receive notifications

answered on May 23, 2020 at 9:25 am

Kaxa user avatar

kaxa kaxa

485 1 1 gold badge 5 5 silver badges 10 10 bronze badges

1

  • After disabling Selinux, I’m facing raw PHP renders. What would you advise? (serverfault.com/q/1109780/619988).

    -Mercury

    Sep 5 at 05:12

Add a comment | 

This answer is helpful

0

This answer is not helpful

View activity on this post.

I had the same problem on a rackspeed server after changing the php version in the cpanel. Turned out that changed the folder permissions as well… I set the folder permission to 755 with

chmod 755 folder_name

compare

Share a link to this answer

Copy link CC BY-SA 4.0

Improve this answer

Follow

Follow this answer to receive notifications

answered on Sep 1, 2020 at 3:00 PM

Black user avatar

black black

16.2k 35 35 gold badges 145 145 silver badges 246 246 bronze badges

1

  • Reason for dislike?

    -Black

    Sep 24, 2021 at 12:16 PM

Add a comment | 

This answer is helpful

-8

This answer is not helpful

View activity on this post.

“Server unable to read htaccess file” means exactly that. Make sure the permissions on your .htaccess file are world readable.

compare

Share a link to this answer

Copy link CC BY-SA 3.0

Improve this answer

Follow

Follow this answer to receive notifications

answered on July 12, 2015 at 8:44 am

200_success user avatar

200_success 200_success

7 104 1 1 gold badge 42 42 silver badges 71 71 bronze badges

1

  • 1

    On a Unix or Linux host? chmod 644 .htaccess

    – 200_success

    Jul 12, 2015 at 8:47 am

Add a comment | 

Very active question . Earn 10 reputation points (not including the association bonus) in order to answer this question. The reputation requirement helps protect this question from spam and unanswered activity.

Not the answer you are looking for? Browse other tagged questions

  • .htaccess

or ask your own question.

  • The overflow blog
  • Availability of five nines without developer exhaustion (Ep. 488)

  • We Hate Scrum and Agile… When Done Badly (Ep. 489)

  • Featured on Meta
  • Recent color contrast changes and accessibility updates

  • Do I need to explain other people’s answers in code?

  • Reviewer overboard! Or a request for improved onboarding guidance for new…

  • Collectives update: recognized members, articles and GitLab

Report this ad

related

0

Unable to load CSS and JS files with forbidden error

3

New Magento Host – 403 Forbidden – Server cannot read htaccess file

0

Django site served on Apache server not working, logs have no error

Related

14

Apache error while configuring Silex Bootstrap: unable to verify htaccess file

3

New Magento Host – 403 Forbidden – Server cannot read htaccess file

12

Forbidden You do not have permission to access/on this server. Server unable to read htaccess file, denying access to be sure

1

Server unable to read htaccess file

0

Unable to read htaccess file – problem with Laravel or permissions?

0

WordPress Server unable to read htaccess file, denying access to be sure

18

The server is unable to read the htaccess file, denying access to be sure

0

when i try to access my website it shows access forbidden

Network burning questions

  • Are there countries in Europe where there’s a 10% (or similar, but low) numeric threshold for minority language rights?
  • Join with comma separated values ​​in SQL without direct relation between tables
  • Valid Inequality Example (Wolsey Example 9.3)
  • Issues with FindRoot. Getting error: FindRoot::eqlist: In the first argument {True,z1==0} only some of the components are equations
  • Construct a meaningful phrase
  • What is the area of ​​the SSME nozzle knowing only thrust at sea level and in vacuum?
  • Vagueness rather than specificity when the risks are enormous
  • “Todes les sábades y dominges”? What is this about?
  • Can I add thick cream to whipping cream to increase fat content and make the whipped cream more stable?
  • For smash burger patties, are you supposed to wait until the meat releases from the pan before you flip it?
  • How do non-English speakers navigate through JFK airport?
  • Does the key a piece is written in affect playability for piano?
  • Do stocks made with less water lack the same flavor as a stock made with lots of water?
  • 1987 Home Build: Multiple 14ga Switch Loops on 20 AMP Circuit
  • Is DNDBeyond correct on the ranger bonus?
  • Can I update a decade-old mountain bike to modern standards?
  • Period of the propagator of quantum harmonic oscillators
  • Can I make my own license?
  • In what situations could “dirty water leak into” municipal water pipes besides a catastrophic loss of pressure?
  • Is the fake ice cream on top of an ice cream truck called an “ice cream figure”?
  • Single-directional linked list in C
  • Stacking: Use predictions of train or test to create features for level 1 classifier
  • Can I bring my dog to on-campus graduate housing?
  • what is the minimal number of lines to ensure there is at least one angle less than 26 degrees (The applications of pigeonhole principle)

Question feed

Subscribe to RSS

Question feed

To subscribe to this RSS feed, copy and paste this URL into your RSS reader.

Server unable to read htaccess file, denying access to be safe

Ask Question

Asked 7 years, 2 months ago

Modified 1 year, 7 months ago

Viewed 337k times

Report this ad

This question shows research effort; it is useful and clear

105

This question does not show any research effort; it is unclear or not useful

23

Bookmark this question.

Show activity on this post.

I have created a simple app using AngularJS. When I tried to host that project in my website http://demo.gaurabdahal.com/recipefinder it shows the following error:

Forbidden

You don’t have permission to access /recipefinder on this server. Server unable to read htaccess file, denying access to be safe

But if I go to http://demo.gaurabdahal.com/ it displays “access denied” message as expected, that I have printed. But why is it unable to open that AngularJS projects “recipefinder”. If I tried to put a simple HTML app there, it opens just fine.

The same AngularJS project works fine when I host that in github (http://gaurabdahal.github.io/recipefinder)

I can’t understand what’s wrong.

  • .htaccess

Share

Share a link to this question

Copy link CC BY-SA 4.0

Improve this question

Follow

Follow this question to receive notifications

edited Sep 2, 2020 at 13:54

yivi user avatar

yivi

37.5k 18 18 gold badges 93 93 silver badges 119 119 bronze badges

asked Jul 12, 2015 at 8:42 am

Saurab user avatar

Saurab Saurab

1,781 4 4 gold badges 17 17 silver badges 33 33 bronze badges

4

  • 1

    possible duplicate new Magento host – 403 Forbidden – Server unable to read htaccess file

    – 200_success

    Jul 12, 2015 at 8:46 am

  • Even if I set the file permission to 777 , it doesn’t work.

    – Saurab

    Jul 12, 2015 @ 8:58 AM

  • 142

    Every time you chmod 777, somewhere in the world a kitten dies

    -Janus

    Jul 12, 2015 at 6:10 PM

  • 1

    If it worked before and it happens out of the blue, try restarting apache first. No more death kittens.

    – sglessard

    Jan 18, 2017 at 9:33 PM

Add a comment | 

15 answers 15

Sorted by: Reset to default

Highest score (default) Trending (recent votes count more) Date modified (newest first) Date created (oldest first)

This answer is helpful

220

This answer is not helpful

View activity on this post.

I had this problem too. My advice is to look in your server’s error log file. For me it was that the top directory of the project was not readable. The error log clearly indicated this. single

sudo chmod 755 <site_top_folder>

fixed it for me.

compare

Share a link to this answer

Copy link CC BY-SA 4.0

Improve this answer

Follow

Follow this answer to receive notifications

modified on September 2, 2020 at 10:12

Black user avatar

Black

16.2k 35 35 gold badges 145 145 silver badges 246 246 bronze badges

answered on February 22, 2017 at 3:56 PM

swedge218 user avatar

swedge218 swedge218

3,093 1 1 gold badge 13 13 silver badges 12 12 bronze badges

3

  • This is because your system folder path doesn’t seem to be set correctly. Please open the following file and correct it: index.php

    – user3787990

    November 21, 2018 at 5:07 am

  • 16

    In my case the top directory was set to 750 (not sure why), change it to 755 and it worked

    -Paul

    Jul 5, 2019 @ 3:35 PM

  • This <site_top_folder> is the most important. You must authorize the ROOT folder. It worked well. Thanks.

    – Chaminda Bandara

    December 14, 2019 at 5:24 PM

Add a comment | 

Report this ad

This answer is helpful

30

This answer is not helpful

View activity on this post.

Set the group in your public directory to nobody.

compare

Share a link to this answer

Copy link CC BY-SA 3.0

Improve this answer

Follow

Follow this answer to receive notifications

answeredJan 6, 2016 at 8:45 am

Mycelin user avatar

Mycelin Mycelin

587 7 7 silver badges 6 6 bronze badges

1

  • 1

    That was the problem I had. Thanks.

    – Art Gegel

    14 avril 2021 à 7:59

Ajouter un commentaire | 

Cette réponse est utile

26

Cette réponse n’est pas utile

Afficher l’activité sur ce post.

Il s’agit d’un problème courant avec l’hébergement de serveurs virtuels GoDaddy lorsque vous ouvrez un nouveau site Web.

En supposant que vous ayez un accès SSH au serveur (vous devez l’activer sur cPanel), connectez-vous à votre compte. Une fois la connexion réussie, vous serez placé dans le répertoire d’accueil de votre compte. Le DocumentRoot de votre site Web se trouve dans un sous-répertoire nommé public_html. GoDaddy définit par défaut les autorisations pour ce répertoire sur 750, mais ces autorisations sont insuffisantes pour permettre à Apache de lire les fichiers du site Web. Vous devez changer les permissions pour ce répertoire en 755 (chmod 755 public_html).

Copy your website files to the public_html directory (scp and rsync work for copying files to a GoDaddy Linux server).

Next, make sure all files under public_html are world readable. To do this, use this command:

cd public_html chmod -R o+r *

If you have other subdirectories (like css, js, and img), make sure they’re accessible to everyone by enabling both read and execute for universal access:

chmod o+rx css chmod o+rx img chmod o+rx js

Finally, you will need to have an .htaccess file inside the public_html file. GoDaddy enforces a rule that prohibits the site from loading if you don’t have an .htaccess file in your public_html directory. You can use vi to create this file (“vi .htaccess”). Enter the following lines in the file:

Order allow, deny Allow all Require all to be granted

This configuration will work for both Apache 2.2 and Apache 2.4. Save the file (ZZ), then make sure the file has 644 permissions:

chmod 644 .htaccess

Works like a charm.

compare

Share a link to this answer

Copy link CC BY-SA 4.0

Improve this answer

Follow

Follow this answer to receive notifications

modified on February 13, 2019 at 1:27 PM

Avatar of Andras Aszodi

Andras Aszodi

8,063 5 5 gold badges 44 44 silver badges 47 47 bronze badges

answeredJan 15, 2016 at 11:15 PM

David Stoddard user avatar

David StoddardDavid Stoddard

269 ​​3 3 silver badges 5 5 bronze badges

1

  • of them

    of course chmod 644 .htaccess is very important otherwise it won’t work! 🙂

    – to light up

    November 4, 2017 at 10:40 am

Add a comment | 

Report this ad

This answer is helpful

twenty one

This answer is not helpful

View activity on this post.

You should run these commands in /var/www/html/ or whatever directory your project is in:

sudo chgrp -R GROUP ./ sudo chown -R USER:GROUP ./ find ./ -type d -exec chmod 755 -R {} \; find ./ -type f -exec chmod 644 {} \;

In my case (apache web server) I use www-data for USER and GROUP

compare

Share a link to this answer

Copy link CC BY-SA 4.0

Improve this answer

Follow

Follow this answer to receive notifications

modified on November 28, 2020 at 8:42 AM

answered on February 11, 2018 at 9:32

Vahid user avatar

Vahid Vahid

5,792 5 5 gold badges 36 36 silver badges 55 55 bronze badges

1

  • 1

    Why do you use sudo chgrp -R GROUP ./ if you already set the group with sudo chown -R USER:GROUP ./ ? It’s redundant

    -Black

    Sep 24, 2021 at 12:07 PM

Add a comment | 

This answer is helpful

13

This answer is not helpful

View activity on this post.

Each public folder gives permission to 755. Issue resolved.

compare

Share a link to this answer

Copy link CC BY-SA 4.0

Improve this answer

Follow

Follow this answer to receive notifications

answered on November 2, 2019 at 0:35 am

rashedcs user avatar

rashedcs rashedcs

3,327 2 2 gold badges 36 36 silver badges 39 39 bronze badges

0

Add a comment | 

This answer is helpful

ten

This answer is not helpful

View activity on this post.

GoDaddy Shared Server Solution

I had the same problem trying to deploy a separate Laravel project at the subdomain level.

File structure

– public_html (where main web app resides) [works fine] – booking.mydomain.com (folder for separate Laravel project) [displays 403 error prohibited]

The solution

  1. go to cPanel of your GoDaddy account

  2. open file manager

  3. navigate to the folder that shows the 403 forbidden error

  4. in the file manager, right click on the folder (in my case booking.mydomain.com)

  5. select Edit permissions

  6. check the following boxes

    a) user – read, write, execute b) group – read, execute c) world – read, execute Authorization code should display as 755

  7. Click edit permissions

compare

Share a link to this answer

Copy link CC BY-SA 4.0

Improve this answer

Follow

Follow this answer to receive notifications

modified on July 23, 2020 at 6:23 PM

answered on February 4, 2018 at 12:27

Armand user avatar

Armand Armand

2 292 2 2 gold badges 23 23 silver badges 36 36 bronze badges

0

Add a comment | 

This answer is helpful

seven

This answer is not helpful

View activity on this post.

Under linux,

find project_directory_name_here -type d -exec chmod 755 {} \; find project_directory_name_here -type f -exec chmod 644 {} \;

It will override all file and folder permissions of project_directory_name_here and its internals.

compare

Share a link to this answer

Copy link CC BY-SA 4.0

Improve this answer

Follow

Follow this answer to receive notifications

answeredNovember 28, 2020 at 6:54 am

Harat User Avatar

Harat Harat

1 148 1 1 gold badge 14 14 silver badges 18 18 bronze badges

1

  • @alib0ng0… Glad I could help

    – Harat

    Jan 14, 2021 at 2:51 PM

Add a comment | 

This answer is helpful

4

This answer is not helpful

View activity on this post.

In my case, apache was somehow misconfigured (?), so I had to set permissions for all parent directories as well. Simply setting the permission to .htaccess (and its parent directory) didn’t work.

compare

Share a link to this answer

Copy link CC BY-SA 4.0

Improve this answer

Follow

Follow this answer to receive notifications

edited July 27, 2020 at 6:05 AM

answered on September 28, 2016 at 9:18 am

MilanG user avatar

MilanG MilanG

6,866 2 2 gold badges 33 33 silver badges 61 61 bronze badges

Add a comment | 

This answer is helpful

4

This answer is not helpful

View activity on this post.

Ok, I recently ran into the same problem while working on a WordPress installation using apache2 on the server running Ubuntu 20.04.

I ran into this problem when I changed ownership of the file to another user:

Here is what worked for me:

$ sudo chown -R www-data:www-data /var/www/YOUR-DIRECTORY

Here’s a bit more context into the problem:

The above command gives ownership of all files [in this folder] to user and group www-data . This is the user under which the Apache web server is running, and Apache will need to be able to read and write WordPress files in order to serve the website and perform automatic updates.

Be sure to point to the relevant directory on your server (replace YOUR-DIRECTORY with your current folder).

You could browse this insightful article on digitalocean.

compare

Share a link to this answer

Copy link CC BY-SA 4.0

Improve this answer

Follow

Follow this answer to receive notifications

modified on February 9, 2021 at 5:53 PM

answered on February 9, 2021 at 5:20 PM

MwamiTovi user avatar

Mwami Tovi Mwami Tovi

2,190 15 15 silver badges 23 23 bronze badges

Add a comment | 

This answer is helpful

3

This answer is not helpful

View activity on this post.

As for Apache running on Ubuntu, the solution was to check the error log, which showed that the error was related to folder and file permission.

First, check Apache’s error log

nano /var/log/apache2/error.log

Then set the folder permission to be executable

sudo chmod 755 /var/www/html/

Also set the file permission to be readable

sudo chmod 644 /var/www/html/.htaccess

compare

Share a link to this answer

Copy link CC BY-SA 4.0

Improve this answer

Follow

Follow this answer to receive notifications

editedSeptember 22, 2019 @ 9:40 PM

answered on September 22, 2019 at 9:32 PM

Lua user avatar

Lua Lua

57 8 8 bronze badges

1

  • Yes, the top directory path should be set as sudo chmod 755 /var/www/html because sometimes the top directory is not set as 755

    –Suraj Bhatt

    Jan 12, 2021 at 6:24 PM

Add a comment | 

This answer is helpful

1

This answer is not helpful

View activity on this post.

Just my solution. I had checked out a file, made some minor changes and got the above error. All deleted, downloaded and extracted again, and normal business.

compare

Share a link to this answer

Copy link CC BY-SA 4.0

Improve this answer

Follow

Follow this answer to receive notifications

answeredFebruary 17, 2019 at 7:03 am

User avatar of user2060451

user2060451 user2060451

2,496 3 3 gold badges 22 22 silver badges 31 31 bronze badges

Add a comment | 

This answer is helpful

0

This answer is not helpful

View activity on this post.

Important points in my experience:

  • every resource accessible by the server must be in an executable and readable directory, hence the xx5 in every chmod in other answers.
  • most of the time the webserver (apache in my case) is neither running as a user nor in the group owning the directory, so again xx5 or chmod o+rx is needed.

But the biggest conclusion I’ve come to is to go from little to more.

For example, if http://myserver.com/sites/all/resources/assets/css/bootstrap.css throws a 403 error, see if http://myserver.com/ works, then sites, then sites/all, then sites/all/resources, and so on.

This will help if your server has directory indexes enabled:

  • In Apache: Options + Index

This instruction may also be in the .htaccess file in the public_html folder of your web server.

compare

Share a link to this answer

Copy link CC BY-SA 3.0

Improve this answer

Follow

Follow this answer to receive notifications

modified on August 30, 2016 at 10:08 PM

dg99 user avatar

dg99

5 156 2 2 gold badges 36 36 silver badges 49 49 bronze badges

answered on August 30, 2016 at 9:35 PM

Avatar of Juan Javier Triff Cabanas

Juan Javier Triff Cabanas Juan Javier Triff Cabanas

483 7 7 silver badges 14 14 bronze badges

1

  • Since the question has already been asked, I’ll post here that I suddenly get the same error on a system that was working a short time ago. According to the Apache2 error.log, it apparently looks for a .htaccess file in /var/www when there never was. There is one in /var/www/html and others in the site folders. Why a sudden error? I am using Ubuntu 19.10.

    – DonP

    January 11, 2020 at 9:35 am

Add a comment | 

This answer is helpful

0

This answer is not helpful

View activity on this post.

I had the same problem on Fedora and found the problem to be selinux. to test that this is a problem, run the command: sudo setenforce 0

Otherwise or change in the file /etc/sysconfig/selinux

SELINUX=application to SELINUX=disabled

or add rules to selinux to allow http access

compare

Share a link to this answer

Copy link CC BY-SA 4.0

Improve this answer

Follow

Follow this answer to receive notifications

answered on May 23, 2020 at 9:25 am

Kaxa user avatar

kaxa kaxa

485 1 1 gold badge 5 5 silver badges 10 10 bronze badges

1

  • After disabling Selinux, I’m facing raw PHP renders. What would you advise? (serverfault.com/q/1109780/619988).

    -Mercury

    Sep 5 at 05:12

Add a comment | 

This answer is helpful

0

This answer is not helpful

View activity on this post.

I had the same problem on a rackspeed server after changing the php version in the cpanel. Turned out that changed the folder permissions as well… I set the folder permission to 755 with

chmod 755 folder_name

compare

Share a link to this answer

Copy link CC BY-SA 4.0

Improve this answer

Follow

Follow this answer to receive notifications

answered on Sep 1, 2020 at 3:00 PM

Black user avatar

black black

16.2k 35 35 gold badges 145 145 silver badges 246 246 bronze badges

1

  • Reason for dislike?

    -Black

    Sep 24, 2021 at 12:16 PM

Add a comment | 

This answer is helpful

-8

This answer is not helpful

View activity on this post.

“The server cannot read the htaccess file” means exactly that. Make sure the permissions on your .htaccess file are world readable.

compare

Share a link to this answer

Copy link CC BY-SA 3.0

improve this answer

Follow

Follow this answer to receive notifications

answered on July 12, 2015 at 8:44 am

200_success user avatar

200_success 200_success

7 104 1 1 gold badge 42 42 silver badges 71 71 bronze badges

1

  • 1

    On a Unix or Linux host? chmod 644 .htaccess

    – 200_success

    Jul 12, 2015 at 8:47 am

Add a comment | 

Very active question . Earn 10 reputation points (not including the association bonus) in order to answer this question. The reputation requirement helps protect this question from spam and unanswered activity.

Not the answer you are looking for? Browse other tagged questions

  • .htaccess

or ask your own question.

  • The overflow blog
  • Five Nines Uptime Without Developer Attrition (Ep. 488)

  • We Hate Scrum and Agile… When Done Badly (Ep. 489)

  • Featured in Meta
  • Recent color contrast changes and accessibility updates

  • Do I need to explain other people’s answers in code?

  • Reviewer overboard! Or a request to improve the onboarding guide for new…

  • Collective update: recognized members, articles and GitLab

Report this ad

Leap

0

Unable to load CSS and JS files with forbidden error

3

New Magento Host – 403 Forbidden – Server cannot read htaccess file

0

Django site served on Apache server is down, logs have no errors

Related

14

Apache error while configuring Silex Bootstrap: unable to verify htaccess file

3

New Magento Host – 403 Forbidden – Server cannot read htaccess file

12

Forbidden You do not have permission to access/on this server. Server unable to read htaccess file, denying access to be sure

1

Server unable to read htaccess file

0

Unable to read htaccess file – problem with Laravel or permissions?

0

WordPress Server unable to read htaccess file, denying access to be sure

18

The server is unable to read the htaccess file, denying access to be sure

0

when i try to access my website it shows access forbidden

burning questions from the net

  • Is the minimization of a strictly convex function always strictly convex?
  • Lowercase or uppercase letters for table entries
  • Non-transport factors
  • Do characters have to wait 24 hours for a long rest, if a long rest is interrupted?
  • Is there a strong correlation between credit rating and mortgage rate in the United States?
  • For smashed burgers, are you supposed to wait for the meat to come off the pan before flipping it?
  • Is a monarch’s title and royal seal changed if the queen has the same name as her former king?
  • What does “2x and 4x with chorus” mean in musical notation?
  • Does scintillating spell metamagic apply to minor spells (e.g. Lightning Arc)?
  • What video game is Spiderhead (2022) playing?
  • Can stem+そう mean rumors?
  • Don’t broths made with less water taste the same as broths made with a lot of water?
  • How important is networking at conferences?
  • Alice’s restaurant benefits allergy sufferers
  • “Every Saturday and Sunday”? What is it about?
  • What does “they might use you as a seed” mean in The Marvelous Land of Oz?
  • 1987 Home Build: multiple 14-gauge circuit breaker loops on a 20-amp circuit
  • How to stick plastic on ceramic tiles?
  • Place a third subfigure in the center in latex
  • Python decibels with metric precision?
  • Is this a breathable atmosphere for human-like extraterrestrials who have blood that is more efficient at carrying oxygen? Normal humans would need a gas (oxygen) mask
  • How to breed the Lilim for real?
  • Is naturalism falsifiable?
  • Period of the propagator of quantum harmonic oscillators

question flow

Subscribe to RSS

question flow

To subscribe to this RSS feed, copy and paste this URL into your RSS reader.


Video Server unable to read htaccess file

Related Posts

Free chat room code for my website

Contents1 How to set up a free chat room on the website.2 3 comentarios2.1 Trackbacks/Pingbacks2.2 Submit a Comment Cancel reply3 How to Create a Chat Room Website…

Background image full screen css

Contents1 Cómo – Full Page Image1.1 Example1.2 Example2 CSS background image tamaño tutorial: how to codify a complete page background image3 Perfect Full Page Background Image3.1 Méthode CSS géniale,…

WordPress leverage browser caching

Contents1 Aproveche el almacenamiento in hidden del navegador1.1 Will it works for my website?1.2 Where are plugin options1.3 Some JavaScript files still display under Leverage Browser Caching1.4…

WordPress post to facebook page

Contents1 How to Automatically Post to Facebook from WordPress1.1 Download Now: How to Launch a WordPress Website [Free Guide + Checklist]1.2 1. Create an IFTTT account.1.3 2….

Download images from wordpress media library

Contents1 How to export your WordPress media library1.1 Download maintenant : How to launch a WordPress website [Free Guide + Checklist]1.2 How to export your WordPress media…

WordPress single post template

Contents1 How to Create Custom Unique Post Templates in WordPress2 Post Template Files2.1 author.php2.2 Fecha.php3 Handbook navigation4 How to Create Custom Single Post Templates in WordPress5 Video…