How to Set AllowOverride all

前端 未结 11 1392
忘掉有多难
忘掉有多难 2020-11-22 10:17

I want to set the AllowOverride all But I don\'t know how to do it. I have found the following code by searching the google and pasted it in .htaccess

相关标签:
11条回答
  • 2020-11-22 11:05

    The main goal of AllowOverride is for the manager of main configuration files of apache (the one found in /etc/apache2/ mainly) to decide which part of the configuration may be dynamically altered on a per-path basis by applications.

    If you are not the administrator of the server, you depend on the AllowOverride Level that theses admins allows for you. So that they can prevent you to alter some important security settings;

    If you are the master apache configuration manager you should always use AllowOverride None and transfer all google_based example you find, based on .htaccess files to Directory sections on the main configuration files. As a .htaccess content for a .htaccess file in /my/path/to/a/directory is the same as a <Directory /my/path/to/a/directory> instruction, except that the .htaccess dynamic per-HTTP-request configuration alteration is something slowing down your web server. Always prefer a static configuration without .htaccess checks (and you will also avoid security attacks by .htaccess alterations).

    By the way in your example you use <Directory> and this will always be wrong, Directory instructions are always containing a path, like <Directory /> or <Directory C:> or <Directory /my/path/to/a/directory>. And of course this cannot be put in a .htaccess as a .htaccess is like a Directory instruction but in a file present in this directory. Of course you cannot alter AllowOverride in a .htaccess as this instruction is managing the security level of .htaccess files.

    0 讨论(0)
  • 2020-11-22 11:05

    enter code hereif you are using linux you have to edit the

    `/etc/apache2/sites-available/000-default.conf`
    

    under the Documentroot . add the following code

    `<Directory /var/www/>
      AllowOverride all
      Require all granted
    </Directory>` 
    

    then ,

    `sudo service apache2 restart`
    

    and you have to enable the apache mod rewrite

    `sudo a2enmod rewrite`
    
    0 讨论(0)
  • 2020-11-22 11:06

    Plus those upvoted correct answers sometimes same error could be seen because of mismatched and different settings on SSL part of webserver configurations. (Obviously when not using .htaccess file).

    0 讨论(0)
  • 2020-11-22 11:11

    In case you are on Ubuntu, edit the file /etc/apache2/apache2.conf (here we have an example of /var/www):

    <Directory /var/www/>
            Options Indexes FollowSymLinks
            AllowOverride None
            Require all granted
    </Directory>
    

    and change it to;

    <Directory /var/www/>
            Options Indexes FollowSymLinks
            AllowOverride All
            Require all granted
    </Directory>
    

    then,

    sudo service apache2 restart
    

    You may need to also do sudo a2enmod rewrite to enable module rewrite.

    0 讨论(0)
  • 2020-11-22 11:14

    I also meet this problem, and I found the solution as 2 step below: 1. In sites-enabled folder of apache2, you edit in Directory element by set "AllowOverride all" (should be "all" not "none") 2. In kohana project in www folder, rename "example.htaccess" to ".htaccess"

    I did it on ubuntu. Hope that it will help you.

    0 讨论(0)
提交回复
热议问题