# Redirect issue

**URL:** <https://www.phphelp.com/t/redirect-issue/35907>\
**Category:** General PHP Help\
**Created:** [December 9, 2023, 10:26am UTC](https://www.phphelp.com/t/redirect-issue/35907 "2023-12-09T10:26:37Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![webchambers](https://www.phphelp.com/letter_avatar_proxy/v4/letter/w/ed655f/32.png) [@webchambers](https://www.phphelp.com/u/webchambers)\
**Post date:** [December 9, 2023, 10:26am UTC](https://www.phphelp.com/t/redirect-issue/35907/1 "2023-12-09T10:26:37Z")

</div>

Hi there.  
Here is a sample link to a page i am using as a header.

```auto
header("Location: https://www.mysite.co.uk/sample/fire/login.php");

```

I am using this on a few pages.

If i change the folder name so say change sample to test i then have to go into all the pages and change the folder name to test !

I have tried this code but it does not work.

```auto
header("Location: <? BASE_URL;?>/fire/login.php");

```

What is the solution ? i want to keep the root just change the folder name ?

Thanks

---

<div class="post-metadata">

**Author:** ![Strider64](https://www.phphelp.com/user_avatar/www.phphelp.com/strider64/32/3161_2.png) [@Strider64](https://www.phphelp.com/u/Strider64)\
**Post date:** [December 9, 2023, 12:31pm UTC](https://www.phphelp.com/t/redirect-issue/35907/2 "2023-12-09T12:31:50Z")

</div>

Maybe the following will help you?

```auto
        $protocol = isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off' ? 'https://' : 'http://';
        $host = $_SERVER['HTTP_HOST'];

        // Define your base path here
        $base_path = ($host === 'localhost:8888') ? '/clearwebconcepts' : '';

        $base_url = $protocol . $host . $base_path;

        $adminItems = [
            'Create Entry' => $base_url . '/create_cms.php',
            'Edit Entry' => $base_url . '/edit_cms.php',
            'Add to Portfolio' => $base_url . '/new_portfolio.php',
            'Edit Portfolio Page' => $base_url . '/edit_portfolio.php',
            'Add Jigsaw' => $base_url . '/add_to_puzzle.php',
            'Edit Jigsaw' => $base_url . '/edit_puzzle.php',
            'Service Form' => $base_url . '/service_form.php'
        ];

        echo '<div class="admin-navigation">';
        foreach ($adminItems as $adminTitle => $adminPath) {
            $adminSafeTitle = htmlspecialchars($adminTitle, ENT_QUOTES, 'UTF-8');
            echo "<a href=\"{$adminPath}\">{$adminSafeTitle}</a>";
        }
        echo '</div>';

```

---

<div class="post-metadata">

**Author:** ![salnazi](https://www.phphelp.com/letter_avatar_proxy/v4/letter/s/59ef9b/32.png) [@salnazi](https://www.phphelp.com/u/salnazi)\
**Post date:** [January 19, 2024, 2:58am UTC](https://www.phphelp.com/t/redirect-issue/35907/3 "2024-01-19T02:58:34Z")

</div>

> [@webchambers](#):
>
> `header("Location: <? BASE_URL;?>/fire/login.php");`

for your case  
define (“BASE\_URL”, “[https://www.mysite.co.uk/sample/](https://www.mysite.co.uk/sample/)”);  
header(“Location:”. BASE\_URL .“fire/login.php”);
