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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T04:10:03+00:00 2026-05-14T04:10:03+00:00

I’m developing an MVC framework in PHP from scratch; mostly for the learning experience

  • 0

I’m developing an MVC framework in PHP from scratch; mostly for the learning experience but this could easily end up in a live project. I went through this tutorial as a base and I’ve expanded from there.

Requests are made like this:

examplesite.com/controller/action/param1/param2/ and so on…

And this is my .htaccess file:

RewriteEngine on

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d

RewriteRule ^(.*)$ index.php?rt=$1 [L,QSA]

So all requests go to index.php and they are routed to the correct controller and action from there. If no controller or action is given, then the default ‘index’ is assumed for both.

I have an index controller with an index action, which is supposed to be the home page of my site. I can access it by going to examplesite.com (since the index part is assumed). It has some images, a link to a stylesheet, and some scripts. They are linked with paths relative to index.php. I thought this would be fine since all request go to index.php and all content is simply included in this page using php. This works if I go to examplesite.com. I will see all of the images and styles, and scripts will run.
However, if I go to examplesite.com/index, I am routed to the correct part of the site, but all of the links don’t work. Does the browser think I am in a different folder?

I would like to be able to use relative paths for all of the content in my site, because otherwise I need to use absolute paths everywhere to make sure things will show up. Is this possible?

  • 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-14T04:10:04+00:00Added an answer on May 14, 2026 at 4:10 am

    You need an absolute path, because browsers evaluate the relative paths relative to the current request uri (unless you use the base tag, see below). Mind you though that an absolute path doesn’t necesseraly mean you need to include the domainname in it. Simply starting with a forward slash is enough. It’s the absolute path relative to the server, so to speak.

    So:

    <img src="/images/bla.gif">

    in stead of

    <img src="images/bla.gif">

    …will work just fine.

    As I’ve mentiond, another approach would be to use the base tag. But for reasons I can’t remember right now, I believe it is recommended to not use it. (If anybody else wants to chime in here…)

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

Sidebar

Ask A Question

Stats

  • Questions 365k
  • Answers 365k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer You can use the data in the /proc filesystem to… May 14, 2026 at 3:57 pm
  • Editorial Team
    Editorial Team added an answer Do you still get the error when you use a… May 14, 2026 at 3:57 pm
  • Editorial Team
    Editorial Team added an answer You can use array_chunk to create a single array comprised… May 14, 2026 at 3:57 pm

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.