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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T23:34:43+00:00 2026-05-17T23:34:43+00:00

I want to include a menu in my php pages. Like this: in index.php

  • 0

I want to include a menu in my php pages. Like this:

in index.php

require_once 'includes/menu.php';

in dir/index.php

require_once 'includes/menu.php';

in menu.php I have:

<a href='link1.php'>Link 1</a>
<a href='link2.php'>Link 2</a>
<a href='link3.php'>Link 3</a>

The problem is that the path should be different for the subdirectory and the root.
How I can handle this, so that the output is link1.php for the index, and ../link1.php for the sub directories?

I found this link, but the question is not very clear, so I don´t known if is related: Change relative link paths for included content in PHP

  • 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-05-17T23:34:43+00:00Added an answer on May 17, 2026 at 11:34 pm

    Here’s one thought: use absolute paths. Putting the href as /link1.php will link to http://www.yourdomain.com/link1.php, regardless of what subdirectory one is in.

    Since I don’t know the particulars of your situation, however, that may not be an acceptable solution. Just putting it out there.

    If your menu is used in different subdirectories to actually refer to different locations, however, e.g. used at /foo/sub/index.php to refer to /foo/link1.php and also used at /bar/sub/index.php to refer to /bar/link1.php, then the HTML base tag might come in handy.

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

Sidebar

Related Questions

So I have a menu in a php file that looks like this (This
<td width=120 valign=top height=100%> <iframe src=menu.php width=100% height=100% frameborder=0> </iframe> </td> This code always
The problem: I want to use PHP include to import file header_menu.html into all
I have an identical horizontal menu at the top of all of my pages,
I have a child page (using masterpages) where I want to include a regular
This menu will need to be updated daily. <html><head></head><body> <h1> Welcome to Burgerama </h1>
Brain freeze here. What I want to do is have the Suckerfish drop down
I have a new project where I am using GWT-Views like Composite, etc. I
I want to include a JavaScript (.js) file on my page. In the JavaScript
I want to include one wav file into dll and play it later. How

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.