[ WordPress.org  ](https://wordpress.org/)

  * [ News  ](https://wordpress.org/news/)
  * [ Showcase  ](https://wordpress.org/showcase/)
  * [ Hosting  ](https://wordpress.org/hosting/)
  * Extend 
    * [ Themes  ](https://wordpress.org/themes/)
    * [ Plugins  ](https://wordpress.org/plugins/)
    * [ Patterns  ](https://wordpress.org/patterns/)
    * [ Blocks  ](https://wordpress.org/blocks/)
    * [ Openverse  ↗  ︎  ](https://openverse.org/)
  * Learn 
    * [ Learn WordPress  ](https://learn.wordpress.org/)
    * [ Documentation  ](https://wordpress.org/documentation/)
    * [ Forums  ](https://wordpress.org/support/forums/)
    * [ Developers  ](https://developer.wordpress.org/)
    * [ WordPress.tv  ↗  ︎  ](https://wordpress.tv/)
  * Community 
    * [ Make WordPress  ](https://make.wordpress.org/)
    * [ Photo Directory  ](https://wordpress.org/photos/)
    * [ Five for the Future  ](https://wordpress.org/five-for-the-future/)
    * [ Events  ](https://events.wordpress.org/)
    * [ Job Board  ↗  ︎  ](https://jobs.wordpress.net/)
  * About 
    * [ About WordPress  ](https://wordpress.org/about/)
    * [ Enterprise  ](https://wordpress.org/enterprise/)
    * [ Gutenberg  ↗  ︎  ](https://wordpress.org/gutenberg/)
    * [ Swag Store  ↗  ︎  ](https://mercantile.wordpress.org/)
  * [ Get WordPress  ](https://wordpress.org/download/)

Search in WordPress.org

[ Get WordPress ](https://wordpress.org/download/)

[ WordPress.org  ](https://wordpress.org/)

[ WordPress Developer Resources ](https://developer.wordpress.org)

esc_url_raw()

  * [ Developer Blog  ](https://developer.wordpress.org/news/)
  * [ Code Reference  ](https://developer.wordpress.org/reference/)
  * [ WP-CLI Commands  ](https://developer.wordpress.org/cli/commands/)

  * [ Developer Blog  ](https://developer.wordpress.org/news/)
  * [ Code Reference  ](https://developer.wordpress.org/reference/)
  * [ WP-CLI Commands  ](https://developer.wordpress.org/cli/commands/)

[ Home ](https://developer.wordpress.org) [ Reference
](https://developer.wordpress.org/reference/) [ Functions
](https://developer.wordpress.org/reference/functions/) esc_url_raw()

Search

#  esc_url_raw(  string  $url  ,  string[]  $protocols  =  null  ):  string

##  In this article

Table of Contents

  * Description 
    * See also 
  * Parameters 
  * Return 
  * More Information 
  * Source 
  * Related 
  * Changelog 
  * User Contributed Notes 

↑  Back to top

Sanitizes a URL for database or redirect usage.

##  Description

This function is an alias for [ sanitize_url()
](https://developer.wordpress.org/reference/functions/sanitize_url/) .

###  See also

  * [ sanitize_url() ](https://developer.wordpress.org/reference/functions/sanitize_url)

##  Parameters

` $url ` string  required

    

The URL to be cleaned.

` $protocols ` string[]  optional

    

An array of acceptable protocols.  
Defaults to return value of [ wp_allowed_protocols()
](https://developer.wordpress.org/reference/functions/wp_allowed_protocols/) .

Default: ` null `

##  Return

string  The cleaned URL after [ sanitize_url()
](https://developer.wordpress.org/reference/functions/sanitize_url/) is run.

##  More Information

The ` esc_url_raw() ` function is similar to ` esc_url() ` (and actually uses
it), but unlike ` esc_url() ` it does not replace entities for display. The
resulting URL is safe to use in database queries and redirects.

Please do not use this function as the only sanitizer for HTTP requests, as
this function is unable to sanitize against security attacks such as [ SSRF
](https://en.wikipedia.org/wiki/Server-side_request_forgery) .

This function is not safe to use for displaying the URL, use ` esc_url() `
instead.

##  Source

    
    
    function esc_url_raw( $url, $protocols = null ) {
    	return sanitize_url( $url, $protocols );
    }
    

[ View all references ](https://developer.wordpress.org/reference/files/wp-
includes/formatting.php/) [ View on Trac
](https://core.trac.wordpre