# redirection/2.7/matches/url.php

Redirection, version 2.7. 33 lines.

- Page: https://pluginprobe.com/plugins/redirection/2.7/code/matches/url.php
- Raw: https://pluginprobe.com/plugins/redirection/2.7/raw/matches/url.php
- Modified: 2017-07-29T14:35:34+00:00

Line numbers below start at 1. Link to a line or a range by appending a fragment to the
page URL, for example `https://pluginprobe.com/plugins/redirection/2.7/code/matches/url.php#L10-L20`.

```php
<?php

class URL_Match extends Red_Match {
	function name () {
		return __( 'URL only', 'redirection' );
	}

	public function save( array $details, $no_target_url = false ) {
		if ( ! isset( $details['action_data'] ) || strlen( $details['action_data'] ) === 0 ) {
			$details['action_data'] = '/';
		}

		if ( $no_target_url ) {
			return null;
		}

		return $this->sanitize_url( $details['action_data'] );
	}

	function get_target( $url, $matched_url, $regex ) {
		$target = $this->url;
		if ( $regex ) {
			$target = preg_replace( '@'.str_replace( '@', '\\@', $matched_url ).'@', $this->url, $url );
		}

		if ( $target === '' ) {
			return $matched_url;
		}

		return $target;
	}
}

```
