is_apache

is_apache global variable can be used to detect which webserver WordPress is running on. It is set in [wordpress root folder]/wp-includes/vars.php as part of the server detection code. It is set in the following manner:

$is_apache=(strstr($_SERVER['SERVER_SOFTWARE'], 'Apache') || 
     strstr($_SERVER['SERVER_SOFTWARE'], 'LiteSpeed')) ? 1 : 0;

is_apache is set to 1 (which means true) if the webserver is either Apache or Litespeed (WordPress.com, i.e., even this blog runs on Litespeed today), which means that both of them can be considered to be practically the same. The other webserver that WordPress supports is Microsoft IIS which is indicated using the global variable is_IIS.

It is possible that certain hosts block the server variable SERVER_SOFTWARE, which can cause problems in using permalinks. is_apache global variable can be forcibly set to 1 for an assured Apache/Litespeed webserver as advised here.

Plugin and theme developers can use these global variables for any web server specific features. One of the biggest features of WordPress – permalinks – requires identification of the web server.

Back to full list of global variables.

Technorati tags: , , , ,

2 Responses to “is_apache”

  1. Abhijit Nadgouda @ iface » Blog Archive » is_IIS Says:

    […] Just like is_apache, is_IIS is part of the web server detection. It is set in [wordpress root folder]/wp-includes/vars.php in the following manner: […]


Leave a Reply

Fill in your details below or click an icon to log in:

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

%d bloggers like this: