Posted by: songbard | May 27, 2011

Coaxing apache to honour OPTIONS

Browsers like FF 3.5 sends a ‘preflight’ OPTIONS request first before sending the actual request in GET/POST. Adding the following directives in httpd.conf will send a 200 response code to client browser without actually executing any handler script and then browser seems to send the POST/GET request – to actually execute script with proper parameters.

# enable cross domain access control 
Header always set Access-Control-Allow-Origin "*" 
Header always set Access-Control-Allow-Methods "POST, GET, OPTIONS" 
 
# force apache to return 200 
RewriteEngine On 
RewriteCond %{REQUEST_METHOD} OPTIONS 
RewriteRule .* / [R=200,L] 

Advertisements

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Categories

%d bloggers like this: