我有Apache 2.4.18(安全补丁),但由于托pipe限制,我不能只更改configuration文件.htaccess 。 mod_headers已启用,我只想在访问www.example.com/ (带有或不带尾部斜线)时才运行Header指令。 LocationMatch '^/$'不允许在.htaccess 。 怎么办?
你可以做到这一点(未经testing)
Header always set CustomHeader my-value "expr=%{REQUEST_URI} =~ m#^/+$#"
类似的东西在Apache文档中详细介绍: https : //httpd.apache.org/docs/current/mod/mod_headers.html