WP_Rewrite::iis7_url_rewrite_rules() WordPress Method

The WP_Rewrite::iis7_url_rewrite_rules() Wordpress method is used to generate rewrite rules for the IIS 7 URL Rewrite module. This is useful for setting up WordPress on IIS 7 servers.

WP_Rewrite::iis7_url_rewrite_rules( bool $add_parent_tags = false ) #

Retrieves IIS7 URL Rewrite formatted rewrite rules to write to web.config file.


Description

Does not actually write to the web.config file, but creates the rules for the process that will.


Top ↑

Parameters

$add_parent_tags

(bool)(Optional) Whether to add parent tags to the rewrite rule sets.

Default value: false


Top ↑

Return

(string) IIS7 URL rewrite rule sets.


Top ↑

Source

File: wp-includes/class-wp-rewrite.php

	public function iis7_url_rewrite_rules( $add_parent_tags = false ) {
		if ( ! $this->using_permalinks() ) {
			return '';
		}
		$rules = '';
		if ( $add_parent_tags ) {
			$rules .= '<configuration>
	<system.webServer>
		<rewrite>
			<rules>';
		}

		$rules .= '
			<rule name="WordPress: ' . esc_attr( home_url() ) . '" patternSyntax="Wildcard">
				<match url="*" />
					<conditions>
						<add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
						<add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
					</conditions>
				<action type="Rewrite" url="index.php" />
			</rule>';

		if ( $add_parent_tags ) {
			$rules .= '
			</rules>
		</rewrite>
	</system.webServer>
</configuration>';
		}

		/**
		 * Filters the list of rewrite rules formatted for output to a web.config.
		 *
		 * @since 2.8.0
		 *
		 * @param string $rules Rewrite rules formatted for IIS web.config.
		 */
		return apply_filters( 'iis7_url_rewrite_rules', $rules );
	}


Top ↑

Changelog

Changelog
VersionDescription
2.8.0Introduced.

The content displayed on this page has been created in part by processing WordPress source code files which are made available under the GPLv2 (or a later version) license by theĀ Free Software Foundation. In addition to this, the content includes user-written examples and information. All material is subject to review and curation by the WPPaste.com community.