Questions tagged [mod-headers]

An Apache module which provides directives to control and modify HTTP request and response headers.

109 questions
92
votes
5 answers

How to set HSTS header from .htaccess only on HTTPS

My web application runs on a different number of hosts that I control. To prevent the need to change the Apache config of each vhost, I add most of the config using .htaccess files in my repo so the basic setup of each host is just a couple of…
nielsr
  • 2,417
  • 2
  • 15
  • 16
28
votes
4 answers

How to check mod_headers and mod_expires modules enabled in apache

I want to check whether mod_headers and mod_expires modules enabled or not in my server Is there a way available to list apache enabled/disabled modules using some php function just like we list php information with phpinfo(); function?
Giri
  • 4,849
  • 11
  • 39
  • 48
25
votes
1 answer

how to use mod_headers and mod_expires to cache

I want to cache images and other files on my site, so what I did is made sure mod_headers and mod_expires with :- /usr/sbin/httpd -l then edited .htaccess to be:- ExpiresActive On ExpiresDefault A0 # Set up caching on media files for 1 year…
user614963
  • 823
  • 3
  • 9
  • 13
23
votes
6 answers

Add Secure and httpOnly Flags to Every Set-Cookie Response in Apache httpd

I'm running Apache 2.2.26: Server version: Apache/2.2.26 (Unix) Server built: Jan 17 2014 12:24:49 Cpanel::Easy::Apache v3.22.30 rev9999 +cloudlinux I'm attempting to use mod_headers to edit Set-Cookie headers and add the secure or httpOnly flag,…
Doug
  • 6,446
  • 9
  • 74
  • 107
21
votes
2 answers

Is it possible to set headers conditionally?

I would like .htaccess to perform the following code ONLY if http_referer is from google (.com/ .ru/ .co.uk /.co.in/ etc.). Is this possible? FileETag None Header unset ETag Header set…
GameDevGuru
  • 1,095
  • 2
  • 12
  • 27
15
votes
3 answers

Is there a way to remove apaches Reverse Proxy Request Headers?

When acting as a reverse proxy, apache adds x-forwarded headers as described here. http://httpd.apache.org/docs/2.2/mod/mod_proxy.html#x-headers In my configuration I have configured server A as a forward proxy. There is a rule like…
The Surrican
  • 29,118
  • 24
  • 122
  • 168
13
votes
1 answer

How to conditionally modify Apache response header 'Location'

I need to be able to test the URL string in a Location response header for a certain pattern and if it matches replace it with another. e.g. if response is Location: http://wrongserver.com I need to change it to Location:…
user3913979
  • 131
  • 1
  • 1
  • 3
13
votes
2 answers

Set Apache headers conditionally

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…
dinosaur
  • 3,164
  • 4
  • 28
  • 40
12
votes
1 answer

Conditionally setting cache headers in apache

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…
mike
  • 213
  • 3
  • 6
11
votes
2 answers

apache How to use "Header set Set-Cookie expires=" dynamically

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…
DavidGamba
  • 3,503
  • 2
  • 30
  • 46
11
votes
4 answers

apache2 mod_headers not working

Question Description: I want to set my site "Access-Control-Allow-Origin", so I set it in apache's config (almost anywhere), but it's not working. I also set other headers for testing, but it's still not working too. Apache version: 2.2.22 Apache…
naivegeek
  • 113
  • 1
  • 1
  • 6
8
votes
2 answers

mod_headers not working

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…
The Mask
  • 17,007
  • 37
  • 111
  • 185
6
votes
1 answer

Mod_deflate and mod_header settings?

I've finally gotten a VPS hosting account set up this allows me to use mod_deflate and mod_header (of course). I'm attempting to make my site faster by YSlow's guidelines which include gzipping (via mod_deflate) the pages and setting a long expire…
Charlie
  • 11,380
  • 19
  • 83
  • 138
6
votes
3 answers

Add expiry headers using Apache for paths which don't exist in the filesystem

For the purposes of CDN invalidation I need to add a prefix to the path element of a site's URL. This is changed whenever a new version of the asset is released. The URL is then rewritten using mod_rewrite from:…
Benedict Dodd
  • 255
  • 3
  • 9
6
votes
2 answers

CORS (Access Control Allow Origin) on Apache Proxy issue

I need to send a CORS header from my map server (QGIS mapserver) that use a fast cgi with Apache 2.4.* on the port 8080. I configured the with a simple [...] Header set Access-Control-Allow-Origin "*" and…
Marcello Verona
  • 540
  • 1
  • 6
  • 10
1
2 3 4 5 6 7 8