Title: apache_mod_loaded
Published: April 25, 2014
Last modified: February 24, 2026

---

# apache_mod_loaded( string $mod, bool $default_value = false ): bool

## In this article

 * [Parameters](https://developer.wordpress.org/reference/functions/apache_mod_loaded/?output_format=md#parameters)
 * [Return](https://developer.wordpress.org/reference/functions/apache_mod_loaded/?output_format=md#return)
 * [Source](https://developer.wordpress.org/reference/functions/apache_mod_loaded/?output_format=md#source)
 * [Related](https://developer.wordpress.org/reference/functions/apache_mod_loaded/?output_format=md#related)
 * [Changelog](https://developer.wordpress.org/reference/functions/apache_mod_loaded/?output_format=md#changelog)

[ Back to top](https://developer.wordpress.org/reference/functions/apache_mod_loaded/?output_format=md#wp--skip-link--target)

Determines whether the specified module exist in the Apache config.

## 󠀁[Parameters](https://developer.wordpress.org/reference/functions/apache_mod_loaded/?output_format=md#parameters)󠁿

 `$mod`stringrequired

The module, e.g. mod_rewrite.

`$default_value`booloptional

The default return value if the module is not found.

Default:`false`

## 󠀁[Return](https://developer.wordpress.org/reference/functions/apache_mod_loaded/?output_format=md#return)󠁿

 bool Whether the specified module is loaded.

## 󠀁[Source](https://developer.wordpress.org/reference/functions/apache_mod_loaded/?output_format=md#source)󠁿

    ```php
    function apache_mod_loaded( $mod, $default_value = false ) {
    	global $is_apache;

    	if ( ! $is_apache ) {
    		return false;
    	}

    	$loaded_mods = array();

    	if ( function_exists( 'apache_get_modules' ) ) {
    		$loaded_mods = apache_get_modules();

    		if ( in_array( $mod, $loaded_mods, true ) ) {
    			return true;
    		}
    	}

    	if ( empty( $loaded_mods )
    		&& function_exists( 'phpinfo' )
    		&& ! str_contains( ini_get( 'disable_functions' ), 'phpinfo' )
    	) {
    		ob_start();
    		phpinfo( INFO_MODULES );
    		$phpinfo = ob_get_clean();

    		if ( str_contains( $phpinfo, $mod ) ) {
    			return true;
    		}
    	}

    	return $default_value;
    }
    ```

[View all references](https://developer.wordpress.org/reference/files/wp-includes/functions.php/)
[View on Trac](https://core.trac.wordpress.org/browser/tags/6.9.4/src/wp-includes/functions.php#L6159)
[View on GitHub](https://github.com/WordPress/wordpress-develop/blob/6.9.4/src/wp-includes/functions.php#L6159-L6190)

## 󠀁[Related](https://developer.wordpress.org/reference/functions/apache_mod_loaded/?output_format=md#related)󠁿

| Used by | Description | 
| [network_step1()](https://developer.wordpress.org/reference/functions/network_step1/)`wp-admin/includes/network.php` |

Prints step 1 for Network installation process.

  | 
| [got_mod_rewrite()](https://developer.wordpress.org/reference/functions/got_mod_rewrite/)`wp-admin/includes/misc.php` |

Returns whether the server is running Apache with the mod_rewrite module loaded.

  |

## 󠀁[Changelog](https://developer.wordpress.org/reference/functions/apache_mod_loaded/?output_format=md#changelog)󠁿

| Version | Description | 
| [2.5.0](https://developer.wordpress.org/reference/since/2.5.0/) | Introduced. |

## User Contributed Notes

You must [log in](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Ffunctions%2Fapache_mod_loaded%2F)
before being able to contribute a note or feedback.