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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T16:54:03+00:00 2026-06-13T16:54:03+00:00

The code below work like this: http://www.website.com/?page=home will pull content from http://www.website.com/home.php — or

  • 0

The code below work like this:

http://www.website.com/?page=home will pull content from http://www.website.com/home.php

— or —

http://www.website.com/?page=About will pull content from http://www.website.com/About.php

Code:

// Set the default name 
$action = 'home'; 

// Specify some disallowed paths 
$disallowed_paths = array('admin'); 

if (!empty($_GET['page'])) { 
    $tmp_action = basename($_GET['page']); 
    // If it's not a disallowed path, and if the file exists, update $action 
    if (!in_array($tmp_action, $disallowed_paths) && file_exists("{$tmp_action}.php")) 
        $action = $tmp_action; 
} 
// Include $action 
include("$action.php"); 
?>

The code above works fine for all my pages but now I have one custom link which I need to add http://www.website.com/?page=Search to pull the content from http://www.website.com/search/search.php instead of http://www.website.com/Search.php

How can I do that?

Thanks

  • 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-13T16:54:04+00:00Added an answer on June 13, 2026 at 4:54 pm

    There are 2 options, you could always look for the file in a sub folder, or you could have a special list of pages with their own paths much like you do with disallowed_paths.

    $special_paths = array(
        "search" => "search/search.php",
    );
    
    if(in_array($_GET['page'], $special_paths)) {
        $action = $special_paths[$_GET['page']];
    

    This would mean if in future another special page exists with a different path you can simply add it to the array.

    Full code would then be:

    <?php
        // Set the default name
        $action = 'home.php';
    
        // Specify some disallowed paths
        $disallowed_paths = array('admin');
    
        // special paths
        $special_paths = array(
                "search" => "search/search.php",
                "special_b" => "a/different/lengthier/path/file.php",
        );
    
        if (!empty($_GET['page'])) {
                $tmp_action = basename($_GET['page']);
    
                // If it's not a disallowed path, and if the file exists, update $action
                if (!in_array($tmp_action, $disallowed_paths) && file_exists("{$tmp_action}.php")) {
                        $action = $tmp_action.".php";
                } elseif(isset($special_paths[$tmp_action])) {
                        $action = $special_paths[$tmp_action];
                }
        }
    
        // Include $action
        include("$action");
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I would like to rewrite the URL of one of my pages from http://www.mydomain.com/some/application/page.html
I have this below code and it work fine header (content-type: text/xml); $xml =
UPDATED: SEE BELOW I've been porting the code for this assignment: http://www.stanford.edu/class/cs221/progAssignments/PA1/search.html (the entire
The below code seems like it should work; however, the blob in the database
This code below doesn't work correctly since my MFC program is in unicode circumstance.
I have an XML document that looks like this: <?xml version=1.0 encoding=UTF-8?> <xs:msgdata xmlns:xs=http://www.myCompany.com
the html looks like below or you can find it here http://www.vbulletin.org/forum/index.php <!-- login
So I ran across this recently: http://www.nicalis.com/ And I was curious: Is there a
Why does the code below work fine when I run my web application localhost
The code below does not work but meant to illustrate what I want to

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.