PHP and Javascript

Asked by:
ashraj98 / 15 Points
2013-01-07 6:59 pm EST
Website Troubleshooting
I tried to run a script that redirects the user based on referrer url in PHP and Javascript, and neither work. Here is my code:

url = "*****URL*****";
if (document.referrer = url) { }
else {window.location = "*****OTHERURL*****"}


$referrer = $_SERVER['HTTP_REFERER'];
$referrer = strtolower($referrer);
$referrer = explode ("/", $referrer);
$referrer = $referrer[2];

$targetref = "*****URL*****";
if ($referrer = $targetref) {
} else {
header( 'Location: *****OTHERURL*****' ) ;

I debugged it and i am sure it's right. Do i have to enable something in cpanel?

To ask this user for more information, please first login.

To submit an answer, please login.



14,932 Points
2013-01-07 7:29 pm EST
Hello Ashraj98,

Your code for both requires some correction. Try reviewing the following links for this issue:

htaccess redirect



If you're still having problems, please respond back with links to your code so that we can review the problem more in depth.

If you have any further questions, please contact technical support or leave a comment at the bottom of the page.


Arnel C.

To submit a comment on this answer, please first login.

Want to share this Question?

Related Articles

It looks like there are no related articles.
Would you like to ask a question about this page? If so, click the button below!

Help Center Search

Current Customers

Email: Ticket: Submit a Support Ticket
Call: 877-595-4HUB (4482)
757-416-6627 (Intl.)
Chat: Click To Chat Now

Ask the Community

Get help with your questions from our community of like-minded hosting users and Web Hosting Hub Staff.

Not a Customer?

Get web hosting from a company that is here to help.