.htaccess files are ignored and do not work

Created:

2016-11-16 13:14:33 UTC

Modified:

2017-06-25 06:39:20 UTC

4

Was this article helpful?


Have more questions?

Submit a request

.htaccess files are ignored and do not work

Applicable to:

  • Plesk for Linux

Symptoms

The rules defined in .htaccess files are ignored.

Cause

.htaccess files support is not enabled.

Resolution

To enable .htaccess files support, create *.conf file in /etc/httpd/conf.d/ with the following content:

AccessFileName .htaccess

<Directory "/var/www/vhosts">
Options +All
AllowOverride All
Order allow,deny
Allow from all
</Directory>

Note: The configuration above is applicable for Apache 2.2. For Apache 2.4 Options +All should be replaced with Options All

Then, restart Apache:

# service httpd restart

Please note that in Debian and Ubuntu the service is named "apache2" instead of "httpd" and the path is /etc/apache2/conf.d/ , instead of /etc/httpd/conf.d/ .

Have more questions? Submit a request

8 Comments

  • 0
    Avatar
    Gerasimos Perentidis

    The fix does not work.

    Also the article is vague.

    **** create *.conf file in /etc/httpd/conf.d/ ****

    What is   "  *.conf  "   ???

    What is the correct name for the file ?

  • 0
    Avatar
    Vitaly Zhidkov

    @Gerasimos, you can give any name to this file. For example "enablehtaccess.conf"

  • 0
    Avatar
    Cihan

    I am getting this error when I want to save the file

    [ Error writing /etc/httpd/conf.d/zz010_psa_httpd.conf: No such file or direct ]

  • 0
    Avatar
    Bulat Tsydenov

    @Cihan, you should not touch this file, it is generated by Plesk automatically. In order to regenerate it, you can run `plesk sbin httpdmng --reconfigure-server`

  • 0
    Avatar
    Cihan

    @Bulat I didn't touch it, it doesn't exist. I read in this document (in German) to do it like that: https://kb.plesk.com/de/124

    Also it doesn't matter how I name the file, always getting the error No such file or direct

  • 0
    Avatar
    Bulat Tsydenov

    @Cihan, it seems you don't have `/etc/httpd/conf.d/` folder. Maybe you are using Ubuntu/Debian? In this case, the path should be /etc/apache2/conf.d/

  • 0
    Avatar
    Alexandros Boukouris

    Not working in Plesk Onyx.

     

    Job for httpd.service failed because the control process exited with error code. See "systemctl status httpd.service" and "journalctl -xe" for details.

    ● httpd.service - The Apache HTTP Server
    Loaded: loaded (/usr/lib/systemd/system/httpd.service; enabled; vendor preset: disabled)
    Active: failed (Result: exit-code) since Tue 2017-05-02 17:26:50 EEST; 23s ago
    Docs: man:httpd(8)
    man:apachectl(8)
    Process: 22295 ExecStop=/bin/kill -WINCH ${MAINPID} (code=exited, status=1/FAILURE)
    Process: 22293 ExecStart=/usr/sbin/httpd $OPTIONS -DFOREGROUND (code=exited, status=1/FAILURE)
    Main PID: 22293 (code=exited, status=1/FAILURE)

    May 02 17:26:50 systemd[1]: Starting The Apache HTTP Server...
    May 02 17:26:50 httpd[22293]: AH00526: Syntax error on line 4 of /etc/httpd/conf.d/enablehtaccess.conf:
    May 02 17:26:50 httpd[22293]: You may not use 'Options +All' or 'Options -All'.
    May 02 17:26:50 systemd[1]: httpd.service: main process exited, code=exited, status=1/FAILURE
    May 02 17:26:50 kill[22295]: kill: cannot find process ""
    May 02 17:26:50 systemd[1]: httpd.service: control process exited, code=exited status=1
    May 02 17:26:50 systemd[1]: Failed to start The Apache HTTP Server.
    May 02 17:26:50 systemd[1]: Unit httpd.service entered failed state.
    May 02 17:26:50 systemd[1]: httpd.service failed.

     

    Obviously the "Options +All" is not accepted by httpd. Is it newer version and needs something else?

    Thanks!

    Edited by Alexandros Boukouris
  • 0
    Avatar
    Nikolay Zhmuk

    2Alexandros, It depends on version of Apache. For Apache 2.4 "Options All" should be used. The article has been updated. Thank you for the input.

Please sign in to leave a comment.