php url from a specific domain

Posted on 2013-09-04
Medium Priority
Last Modified: 2013-09-04
using php is there a way to make a URL not show unless it comes from a specific domain?
Question by:rgb192
LVL 62

Expert Comment

by:Julian Hansen
ID: 39462885
Show where?
LVL 36

Accepted Solution

Loganathan Natarajan earned 1000 total points
ID: 39462920
you can use HTTP_REFERER  .. to check for specific domain request...


// check the request coming from specific domain
$refData = parse_url($ref);

if($refData['host'] == 'domain.com') 
  // redirect to the url page
  header('Location: http://localhost...');
	echo "Invalid request";	


Open in new window

LVL 111

Assisted Solution

by:Ray Paseur
Ray Paseur earned 1000 total points
ID: 39463721
HTTP_REFERER will work some of the time.  The times when it will fail are when the client request comes from an attack vector or from a cURL request which can spoof the value.

What is the business need here?  If you explain that for us then we may be able to suggest some solutions.

Author Closing Comment

ID: 39464548

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

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…
I recently worked on a Wordpress site that utilized the popular ContactForm7 (https://contactform7.com/) plug-in that only sends an email and does not save data. The client wanted the data saved to a custom CRM database. This is my solution.
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

619 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