【问题标题】:.htaccess: AddHandler for a single file?.htaccess:单个文件的 AddHandler?
【发布时间】:2017-09-18 03:29:17
【问题描述】:

我知道AddHandler 指令允许您将文件扩展名与进程相关联。

是否可以将单个文件与进程相关联?

比如我想处理something.css去运行一个PHP脚本来动态生成一些CSS。

从我目前阅读的内容来看,可能会使用类似的东西:

<Files something.css>
    # go off to PHP script
</Files>

……但我不知道下一步该做什么。

【问题讨论】:

    标签: php .htaccess addhandler


    【解决方案1】:

    好的,这就是我的工作方式:

    #   .htaccess
        <Files something.css>
            RewriteEngine On
            RewriteRule ^(.+)$ /styles/something.php [QSA,L]
        </Files>
    

    这会直接进入/styles/ 目录,因为您不能在Files 指令中指定目录。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2023-03-15
      • 2020-03-22
      • 1970-01-01
      • 2016-01-14
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多