How to disable cgi in htaccess in a non-extension dependant way?

和自甴很熟 提交于 2020-03-02 04:53:28

问题


I would like to disable any kind of CGI execution in a directory below my document root directory. Any kind: php, perl, ruby... whatever. I would like to do it in a manner it's not depensant of the file extension. Below my document root because users have to be able to put and see HTML files.

It has to be in htaccess, because it's a shared hosting.

Using -ExecCGI alone is not working. I have to add to that line a AddHandler directive which is extension dependant.

I have found some close answer in this topic, but they are extension dependant, php dependant or global apache configuration dependant.

Is it possibly to do what I want?

Thank you very much,


回答1:


RemoveHandler .suffix where .suffix is the filename suffix for the type of a script you want to disable should do it.

Looking for something that disallows scripts in general right now.

Edit: Aha! If you don't mind having to serve everything in the directory as static content — you probably don't, that's what your question seems to imply — you could just set the default handler for that location.

<Directory something>
    SetHandler default-handler
</Directory>

default-handler is in core so this shouldn't depend on anything. Correct me if I'm wrong.



来源:https://stackoverflow.com/questions/7454504/how-to-disable-cgi-in-htaccess-in-a-non-extension-dependant-way

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