Get Current URL

I was create a custom error page.
 can I get a string containt current URL error ?

as, if you type http://www.mydomain.com/errorrerrs
this is will show custom error page (404).

 How I can echo current URL ("http://www.mydomain.com/errorrerrs") ?


Thank for your patience

Best Regards
bonbonkoreanAsked:
Who is Participating?
 
gonzoramaConnect With a Mentor Commented:
You can get that stuff from the ENVironment variables.
They should be located in the $_SERVER global array.

try doing this:
print_r($_SERVER);

you should be interested in:
$_SERVER['HOST'];
$_SERVER['PHP_SELF'];
$_SERVER['QUERY_STRING'];

HTH
0
 
ragnorusCommented:
Your web host must allow you to access the file: .htaccess in order to create custom 404 error pages.  Web hosts normally don't advertise saying that they DO allow you change .htaccess in their hosting plans/packages., so you'll have to ask them yourself (do NOT try it out if you don't know, it can result to messing up your entire domain)

If you find out that you have access to it, go to notepad (or any other text editor of your choice) and type:

ErrorDocument 404 http://www.mydomain.com/errorerrs

Then save the file as: ".htaccess" (With the quotes..yes..that's an 8 character-long extension)

Then just ftp the file to your root directory.

Hope that helps
0
 
ragnorusCommented:
I guess I misread.  You can't get that info from php.  Why?  Because if there WAS a 404 error, then the user wouldn't be able to access your php code in the first place.

If you want to be notified of an error on your page (which is why you probably want to get the string), then you can redirect the 404 error to a php page.  That php page can email you, telling you that there was a 404 error.

www.freewebmasterhelp.com/tutorials/htaccess will give you some basic knowledge of the .htaccess file and customized page errors.
0
 
bonbonkoreanAuthor Commented:
well ! :D

thanks you for your reply !
 
 But I was found it.

 If I type a error page, as http://www.mydomain.com/testtest

 A 404 page will show, and a value $_SERVER['QUERY_STRING']
have "404;http://www.mydomain.com/testtest"

And I can get the URL error: http://www.mydomain.com/testtest

thanks, gonzorama. You right.
thanks, ragnorus because your comment !
0
All Courses

From novice to tech pro — start learning today.