mod-headers

What's the opposite of “Header append Vary User-Agent”, how to remove the “User-Agent” string from “Vary”?

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-24 10:35:25
问题 I know that I can add the User-Agent to the Vary http header with this line in my .htacess: Header append Vary User-Agent But how can I remove the User-Agent from the Vary header if it is already set? According to the mod_headers doc there is an append option, but no equivalent "remove" option. 回答1: Simple answer below, but you need some shenanigans to avoid sending an empty Vary: header (try to avoid it out of paranoia) Header edit Vary (.*)User-Agent(.*) $1$2 # Remove leading or trailing ',

apache How to use “Header set Set-Cookie expires=<date>” dynamically

痞子三分冷 提交于 2019-12-23 07:11:24
问题 I am using apache as a load balancer and reverse proxy. For session stickiness I am creating a cookie with the route of the node. Header set Set-Cookie "h=.%{BALANCER_WORKER_ROUTE}e; path=/; domain=.domain.com" env=BALANCER_ROUTE_CHANGED How do I set the expires value in the cookie to be X minutes from when the request comes in? The documentation for mod_headers Doesn't even cover Set-Cookie in detail so there is no info there on a dynamic syntax to use for expires . I tried setting the max

htaccess mod_headers for no-caching

对着背影说爱祢 提交于 2019-12-23 02:53:48
问题 We have an application that allows users to add/edit/replace/delete content (text, images, swfs, mp3s, etc). We want the admins to always have the latest updated files by using a no-cache header and when a user runs the application, everything gets/uses the cache. I have looked into solutions and have tried using html meta tags like: <meta http-equiv="expires" content="0" /> <meta http-equiv="cache-control" content="no-cache, no-store" /> <meta http-equiv="pragma" content="no-cache" /> But

Conditionally setting cache headers in apache

感情迁移 提交于 2019-12-20 12:22:32
问题 I want to conditionally set cache headers depending on what path files are accessed from. Basically, accessing http://www.example.com/cache/$cache_key/* should serve files with far in the future cache headers. I'm using a rewrite rule to set an environment variable and then attempting to set cache control headers based on that variable. However, it seems like the variable is being set too late in the process or something; the conditional header rules are never getting executed. RewriteRule

Conditionally setting cache headers in apache

痴心易碎 提交于 2019-12-20 12:22:12
问题 I want to conditionally set cache headers depending on what path files are accessed from. Basically, accessing http://www.example.com/cache/$cache_key/* should serve files with far in the future cache headers. I'm using a rewrite rule to set an environment variable and then attempting to set cache control headers based on that variable. However, it seems like the variable is being set too late in the process or something; the conditional header rules are never getting executed. RewriteRule

Apache won't set headers for PHP script

柔情痞子 提交于 2019-12-17 20:25:36
问题 This .htaccess file: <IfModule mod_expires.c> ExpiresActive On ExpiresDefault "access plus 4 month" </IfModule> <IfModule mod_headers.c> Header merge X-ModHeaders "Yes, it is installed" </IfModule> ... works as expected in my development box (Windows box, Apache/2.4.10, PHP running as Apache module), where "works" means that it generates the appropriates headers for all resources (static or dynamic). However, in my production server (Linux box, Apache/2.2.31, PHP running as FastCGI with mod

Read header into environment variable in Apache 2.2?

荒凉一梦 提交于 2019-12-12 16:41:34
问题 I want to process a request header using a custom rewrite map. Therefore I want to have the content of the header in an environment variable. I have not found a way to do that with mod_headers and/or mod_rewrite. Any help is appriciated. 回答1: Mod_rewrite example for the request header "X-Forwarded-For": RewriteRule .* - [E=X-Forwarded-For:%{HTTP:X-Forwarded-For}] 来源: https://stackoverflow.com/questions/7224561/read-header-into-environment-variable-in-apache-2-2

mod_headers not working

两盒软妹~` 提交于 2019-12-04 23:11:00
问题 I enable mod_headers and mod_rewrite in my http.config removing the # from line. LoadModule headers_module modules/mod_headers.so LoadModule rewrite_module modules/mod_rewrite.so I need enable more something or the error is on .htaccess? .htaccess. RewriteEngine On RewriteRule ^(.*?)\.x$ /$1.php [L] <IfModule mod_headers.c> <filesMatch "\.(x)$"> Header set foo "baa" </filesMatch> </IfModule> Thanks in advance! 回答1: Try loading the headers module with sudo a2enmod headers sudo service apache2

Set Apache headers conditionally

巧了我就是萌 提交于 2019-12-03 17:58:02
问题 I'm working with an apache server, and I'd like to add headers conditionally. If the URI matches a certain regex, I'd like to add the header Access-Control-Allow-Origin: * . What is a good way to do this? What I've tried so far: I added code called by the request handler, using apr_table_add(rq->headers_out, "Access-Control-Allow-Origin", "*") . But it seems like Apache strips the header before sending the response whenever the header Content-Type: application/x-javascript is also set. Is

Conditionally setting cache headers in apache

我是研究僧i 提交于 2019-12-03 02:32:41
I want to conditionally set cache headers depending on what path files are accessed from. Basically, accessing http://www.example.com/cache/$cache_key/* should serve files with far in the future cache headers. I'm using a rewrite rule to set an environment variable and then attempting to set cache control headers based on that variable. However, it seems like the variable is being set too late in the process or something; the conditional header rules are never getting executed. RewriteRule ^cache/.*?/(.*) /$1 [env=asset:true,L] Header set Cache-control "max-age=30" Header set Cache-Control