Is my nginx rewrite correct?

I am using this config:

/test/((^'.)+)$ /test/index.php?id=$1

for my website APKLala. And for the redirection for non trailling slash am writing:

if(substr($_GET('id'), -1) != '/'){ //if no trailling slash then redirect! header("HTTP/1.1 301 Moved Permanently"); header("Location: ".get_bloginfo('url').'/test/'.$_GET('id').'/'); exit();

I just wanted to know that am i doing it right?