php - Header not redirecting if __DIR__ is used -


header ('location:'.__dir__.'/view/prijava_view.php' 

if use above header in index.php file shows blank page "localhost" url. works if use include instead of header though.

is issue dir magic constant? seems can't use in headers, or have problem code?

__dir__ file-system path. has nothing urls client browsers see. if site's files physically stored @

/home/sites/example.com/html/view/projava_view.php 

and code inside php script looks @ dir, you'll get

/home/sites/example.com/html/view/ 

if pass out via header() redirect, you'll redirecting file-system path

header("location: http://example.com/home/site/example.com/html/view/....."); 

which not reachable external users. path not inside document root, , browser requesting full path, server tack on document root again, full end-request be

/home/sites/example.com/html/view/home/sites/example.com/html/view/projava_view.php 

in general, __dir__ magic constant utterly useless when trying build url-space paths, because it's not intended use in urls.


Comments

Popular posts from this blog

html - How to style widget with post count different than without post count -

How to remove text and logo OR add Overflow on Android ActionBar using AppCompat on API 8? -

javascript - storing input from prompt in array and displaying the array -