Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7745189
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T09:57:05+00:00 2026-06-01T09:57:05+00:00

I have a client. Let’s say their domain is www.mydomain.com. We are creating a

  • 0

I have a client. Let’s say their domain is http://www.mydomain.com.

We are creating a new page at http://www.mydomain.com/newsection.

On the /newsection page, the client would like to add a link that says “Go back to main site” (www.mydomain.com) ONLY if the user was previously on the main site before.

So, I set up a code snippet of PHP like this:

<?php
$referral = $_SERVER['HTTP_REFERER'];
if (preg_match('/http://www.mydomain.com/', $referral)) {
echo "from My Domain";
} else {
echo "not from My Domain";
}
?>

However, this always returns false (“Not from My Domain”), even if the user is coming from mydomain.com.

Are there any obvious syntax errors or other logic issues that I’m not getting?

Is the issue that my new page (www.mydomain.com/newsection) is still on that main domain?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T09:57:07+00:00Added an answer on June 1, 2026 at 9:57 am

    The slashes in the expression need to be escaped because they’re also the delimiter. Alternatively, you can choose another delimiter:

    preg_match('~http://www\.mydomain\.com~', $referral)
    

    Note I also escaped the .s, which are special characters in regular expressions. They won’t break the regex, but they match any character – probably not what you want.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I would have question regarding web services. Let's say I have webservice client that
The problem: let's say I have two tables Client , and Product , in
I have a client that would like to add a feature to their application
I am writing a cgi page in Python. Let's say a client sends request
Let's say I have a server listening on port 1234. I have some client
Let's say I have my client application and it makes a connection to the
Unusual situation. I have a client, let's call them BuyNow. They would like for
I wish to let client to have a pretty print page from a web
Let's say I have 2 servers (server and authenticator), and I have a client.
We have a client who already has an app (let's say A) in the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.