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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T03:21:16+00:00 2026-06-12T03:21:16+00:00

I am new about this redirection and I want to know how it works?

  • 0

I am new about this redirection and I want to know how it works?
I have some file called index.php and i want to hadlle it any directory in the site

 index.php

<?php 
    if(empty($dir)){
    include('includes/home.php');
    }  
    if($dir=='profile'){
    include('includes/profile.php');
    }
    elseif($dir=='settings'){
    include('includes/settings.php');
    }
    else{
    include('includes/404.php');
    }
    ?>

The url is:

test 1. www.example.com/ - will view the include home.
test 2. www.example.com/settings - will view the include  settings.
test 3. www.example.com/errorsample - will view the include   404 page.

How to make .htaccess and index.php using that code or any idea how it works and sample code of it.

  • 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-12T03:21:17+00:00Added an answer on June 12, 2026 at 3:21 am

    I will try to explain this with a simple example. Consider the following .htaccess file

    Options +FollowSymLinks
    RewriteEngine On
    RewriteRule ^(.*)$ /index.php?x=$1 [L] 
    #  ^ This is the rule that does the redirection
    

    What it does is, it routes every url request and sends the request to index.php. How it send it? I will show couple of example to do that.

    • www.example.com/settings will be send as www.example.com/index.php?x=settings
    • www.example.com/errorsample will be send as www.example.com/index.php?x=errorsample

    So, now you are configure your index.php and decided what you want to do, with the value you get in $_GET['x']

    switch($_GET['x']) {
       case "profile": include("include/profile.php"); break;
       // .... similarly other cases
       default: include("includes/home.php"); break;
    }
    

    }

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

Sidebar

Related Questions

New to PHP and MySQL, have heard amazing things about this website from Leo
I just started to read about this new technology... Does someone have some knowledge
everyone! new to here and been pondering about this myself for some times with
So I'm trying out this new TDD thing (about time haha). Anyways I have
I have searched the BlackBerry website and developer forum for any details about this
I know what CSS Reset is, but recently I heard about this new thing
I m new about this topic (code first development). I want to do relationship
The compiler complains about this code: HashMap<String,int> userName2ind = new HashMap<String,int>(); for (int i=0;
I am new to perl, and can't seem to find answers about this anywhere.
I'm about to start a new project. The purpose of this project will be

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.