Centos htaccess not being read

半腔热情 提交于 2019-12-03 13:42:42

问题


I'm working on a new server and I installed via yum the "Web Server" group. Php and mysql work fine but I can't get .htaccess to work.

Heres my test .htaccess file:

WASD_TEST_CALL_ERROR

I put this as .htaccess in a test folder along with an index.html page. Instead of reporting an error it goes ahead and loads the index page without displaying any errors.

Thanks


回答1:


Make sure AccessFileName set to .htaccess

Search httpd.conf for AccessFileName directive. It defines name of the distributed configuration file:

grep -i AccessFileName httpd.conf

Make sure users are allowed to use .htaccess file

What you can put in these files is determined by the AllowOverride directive. This directive specifies, in categories, what directives will be honored if they are found in a .htaccess file. If this directive is set to None, then .htaccess files are completely ignored. In this case, the server will not even attempt to read .htaccess files in the filesystem.

grep -i AllowOverride httpd.conf

When this directive is set to All, then any directive which has the .htaccess Context is allowed in .htaccess files: AllowOverride All

Save and close the file. Restart httpd:

service httpd restart



回答2:


Have you set AllowOverride in Apache config? If not, set AllowOverride from none to all.




回答3:


On CentOS7, the following should help:

  1. Under string AllowOverride controls what directives may be placed in .htaccess files in /etc/httpd/conf/httpd.conf:replace AllowOverride None to AllowOverride All

  2. In /etc/httpd/conf.modules.d/00-base.conf check rewrite_module must be:

    LoadModule rewrite_module modules/mod_rewrite.so

  3. .htaccess file must be in /var/www/html/

  4. Example content .htaccess:

    AuthUserFile /var/www/.htpasswd AuthGroupFile /dev/null AuthName "Please Enter Password" AuthType Basic Require valid-user
  5. check and restart Apache:

    httpd -t

    /bin/systemctl restart httpd.service



回答4:


its very simple please find the below image



来源:https://stackoverflow.com/questions/8551740/centos-htaccess-not-being-read

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!