【问题标题】:Using .htaccess or Apache Handler使用 .htaccess 或 Apache 处理程序
【发布时间】:2017-07-24 20:10:15
【问题描述】:

我希望我的共享网络服务器能够像处理“.php”文件一样处理“.ncs”文件。 我知道这可以通过在 Apache Handler 中添加一个条目来轻松完成。参考:http://php.net/manual/en/security.hiding.php

但正如我提到的,我正在使用共享主机,我在 Apache Handler 上所做的任何更改都将不起作用。这些列表仅供参考。我在网站提供商的支持面板中打开了一张票,他们告诉我应该为此使用 .htaccess 文件。但我无法理解我如何使用 .htaccess 文件来处理 .ncs 文件,就像 .php 文件一样。

【问题讨论】:

标签: php apache .htaccess file web


【解决方案1】:

您需要在服务器根目录的 htaccess 上使用 AddType 处理程序:

AddType application/x-httpd-php .ncs

但是如果你将 PHP 作为 CGI 运行,你也需要使用 AddHandler:

AddType application/x-httpd-php .ncs
AddHandler application/x-httpd-php .ncs

【讨论】:

  • 这是我的根目录 .htaccess 文件的内容: SetOutputFilter DEFLATE BrowserMatch ^Mozilla/4 gzip-only-text/html BrowserMatch ^Mozilla/ 4\.0[678] no-gzip BrowserMatch \bMSI[E] !no-gzip !gzip-only-text/html SetEnvIfNoCase Request_URI .(?:gif|jpe?g|png)$ no-gzip dont-vary Header append Vary User-Agent env=!dont-vary 在哪里添加建议的代码 sn-p?
  • 在文件的完整开头。
  • 我试过了。但还是一无所获。 PHP 服务器仍未评估 pinfo.ncs 文件的语句。
  • 尝试使用 x-httpd-php5,听起来很奇怪,但服务器可以配置不同。
猜你喜欢
  • 2011-06-05
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2013-09-04
  • 1970-01-01
  • 2010-09-16
  • 2020-03-23
  • 1970-01-01
相关资源
最近更新 更多