?
Solved

Get Current URL

Posted on 2003-03-03
4
Medium Priority
?
293 Views
Last Modified: 2012-08-13
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
0
Comment
Question by:bonbonkorean
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 

Expert Comment

by:ragnorus
ID: 8061931
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
 

Accepted Solution

by:
gonzorama earned 300 total points
ID: 8062330
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
 

Expert Comment

by:ragnorus
ID: 8062525
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
 

Author Comment

by:bonbonkorean
ID: 8063452
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

Featured Post

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Password hashing is better than message digests or encryption, and you should be using it instead of message digests or encryption.  Find out why and how in this article, which supplements the original article on PHP Client Registration, Login, Logo…
Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
The viewer will learn how to count occurrences of each item in an array.
Suggested Courses

743 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question