I am trying to redirect on a node add form submission our custom url
like SITE_NAME/media/mary's-blog/test-title using following code

function hook_node_insert($node){

 $redirect_url = SITE_NAME.'media/mary's-blog/test-title';
$form['#redirect'] = $redirect_url ;

...

Redirection is not work and page goes to 404 page
its turn out the url value as SITE_NAME.media/mary039s-blog/test-title

Comments

jaypan’s picture

Apostrophe's are not allowed in URLs. Also, you need a slash after SITE_NAME

Contact me to contract me for D7 -> D10/11 migrations.

chetan-singhal’s picture

use this
$_GET['destination']=$redirect_url ;

$form['#redirect'] will not work because in node_insert $node is pass as arguement not $form. keep in mind that what is passing in argument.

chetan