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 9023803
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T05:50:59+00:00 2026-06-16T05:50:59+00:00

I have a multilingual website, the change language functionality works like this: change_lang.php?lang=en&return=www.example.com/pages/etc in

  • 0

I have a multilingual website, the change language functionality works like this:

change_lang.php?lang=en&return=www.example.com/pages/etc

in change_lang.php I read the $_GET['return'] and $return_addr = $_GET['return'] then use header("location:" . $return_addr) to send the user back to the place he was, now Imagine someone wants to pollute the return address:

change_lang.php?lang=en&return=www.HACKER-SITE.com/virus.exe

For preventing this, I want to limit the $return_addr value to only local machine(server), my code is:

<?php
    if(substr(BASE_URL, 0, 8) == 'https://'){
        $start_len = 8;
        $return_http = 'https://';
    } else{
        $start_len = 7;
        $return_http = 'http://';
    }
    $http_extracted_base_url = substr(BASE_URL, $start_len);
    if(substr($http_extracted_base_url, 0, 10) == substr($return, 0, 10)){
        // OK
    }else{
        // NOT OK
        exit();
    }
    ?>

BASE_URL is a defined value of my domain, like http://example.com, the above code works well when the user is not using “www” in his address, but when he does, I need to check another thing on my code, all of this must have a better solution, and that’s my question; how I’m supposed to check if the return URL is going back to the site itself, I don’t want to check https r www, or also we may want to have another domain in future parked on our site, so some users may use the second address and the above code fails since BASE_URL is defined as the first domain.

P.S: I don’t want to PING the domain of return address, execution functions are disabled on the server.

  • 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-16T05:51:03+00:00Added an answer on June 16, 2026 at 5:51 am

    I’d suggest using $_SERVER['HTTP_REFERER'] or your defined BASE_URL

    <?php
    
        // your language handling code
    
        $redirect = isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : BASE_URL;
        header("Location: {$redirect}\r\n");
        exit;
    

    I will add that while this could be manipulated (so I’m told) surely the only person it would affect is the user that manipulated that header, as they are being redirected?

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

Sidebar

Related Questions

I'm writing multilingual website. I have several files on server like: /index.php /files.php /funny.php
I have a model for a multilingual website with wiki functionality which contains various
I have a multilingual website (Chinese and English). I like to validate a text
We are now using Django to develop a multilingual website. We have different language
I'm building a multilingual website that uses PHP to load language files. Paragraphs in
I have built a multilingual website with CodeIgniter using this library: http://codeigniter.com/wiki/URI_Language_Identifier/ I use
I am going to build a multilingual website with PHP and need to have
I started using ModX yesterday. Prepared my multilingual website using this tutorial: http://www.multilingual-modx.com/blog/2011/multilingual-websites-with-modx-and-babel.html .
Hi i have develop and deploy one multilingual (english uk and swedish) website at
I have several table related to multilingual Photo Galley like AlbumCategories AlbumName Photos PhotoDetails

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.