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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T10:28:31+00:00 2026-06-14T10:28:31+00:00

I have the following file structure on my PHP localhost: Root css/ main.css admin/

  • 0

I have the following file structure on my PHP localhost:

  • Root
    • css/
      • main.css
    • admin/
      • admin.php
    • index.php
    • header.php

Both admin.php and index.php are requiring header.php, in which main.css is included like the following:

    <link rel="stylesheet" type="text/css" 
        href="<?php echo $_SERVER['DOCUMENT_ROOT']; ?>/css/main.css" />

However, the css file isn’t included properly. When I look at the Source Code in Chrome on Mac, The browser has turned that into

http://localhost/Users/ljhljh235/Documents/web/hetd/css/main.css

in which http://localhost is not intended to be here. Could anybody help me on how to build the correct absolute path for the css file?

P.S. My way of including header.php in admin.php and index.php is

require_once ($_SERVER['DOCUMENT_ROOT'].'/header.php');

And I’m using MAMP 2.1.1.

Thanks for any help.

  • 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-14T10:28:32+00:00Added an answer on June 14, 2026 at 10:28 am

    The variable $_SERVER[‘DOCUMENT_ROOT’] is for server side path, use /css/main.css only, it will be relative to the domain ie : http://domain.com/css/main.css

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

Sidebar

Related Questions

I have the following file structure: /framework /.htaccess /index.php and the following rules in
I have the following files structure: temp main index.php a.php b.php Here are the
I have the following folder structure with files: index.php includes/header.php includes/conn.php contents/ad_list.php contents/ad_posting.php in
I have the following file structure: |- index.html vendor |- jquery.min.js (some libraries) js
I have the following structure: -uploadpage.html -index.php -resources -jquery-1.4.2.min.js On my index.php, I get
I'm using Iirf v2.0 . I have the following directory structure: / /library /library/index.php
Please consider the following structure of my website: www.mydomain.com/ www.mydomain.com/index.php www.mydomain.com/404.php www.mydomain.com/css www.mydomain.com/blog/ How
I have the following PHP code to display the file structure of my site.
I have the following directory structure in htdocs: htdocs/ .htaccess index.php foo/ bar/ priv/
I have the following file structure: cron.php /includes/functions.php /classes/ClassName.php corn.php includes functions.php calls new

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.