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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T22:15:20+00:00 2026-05-25T22:15:20+00:00

I have a custom PHP framework in which everything after the domain is sent

  • 0

I have a custom PHP framework in which everything after the domain is sent to PHP as a $_GET variable, like so:

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

All routing is done by a router file. For example, http://domain.tld/page gets sent to http://domain.tld?page_request=home.

However, if I have a directory-like structure (i.e. http://domain.tld/page/), the request is sent, but any relative URLs in the HTML are now relative to /page, even though we’re still in the root level in the domain.

To clarify:

Going to http://domain.tld/page and requesting res/css/style.css in HTML returns a stylesheet.

Going to http://domain.tld/page/ and requesting res/css/style.css returns an 404 error, because the page/ directory doesn’t actually exist.

What’s the best way to work around this? This seems really simple, but I’m not quite good enough with .htaccess yet to do it off the top of my head. Thanks for any answers in advance.

Edit: Also, my .htaccess file contains:

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

Edit #2: Yes, I know about using the leading /.

However, I can’t do that with this particular website, because it’s a subfolder on a server, so linking to / would go to the root of the server and not the site.

If I put /subfolder/css for every link on the site, that would not only get tedious, but also problematic were the subfolder to change. Is there a better way to work around this?

  • 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-25T22:15:20+00:00Added an answer on May 25, 2026 at 10:15 pm

    The other answers that say you have to absolutize the paths are correct. If you are working in a subfolder, there are two things that you can/should do to help:

    1) Use RewriteBase in your htaccess file

    RewriteEngine on
    RewriteBase /framework/
    
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^(.*)/?$    index.php?url=$1    [QSA,L]
    

    2) Create a constant in your framework that has that same path

    define('FULL_PATH', '/framework');
    

    Then each time you create a URL in html, make sure you do something like

    <a href="<?= FULL_PATH ?>/your/remaining/path">
    

    It’s a little bit of extra work to think about this each time you create a URL on the page, but it will serve you well in the long run.

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

Sidebar

Related Questions

I have a custom built application framework written in PHP which I have been
I currently have a custom session handler class which simply builds on php's session
I have a load of php templates which uses a custom translate function __,
I have a website which uses the custom 404 error handling in PHP/Apache to
I have a custom-built MVC PHP framework that I am in the process of
I have a custom PHP framework and am discovering the joys of storing configuration
I have a custom iterator (TokenIterator to be precise, which iterates, well, tokenized php
I have a (custom) php framework that contains following structure: app |-classes |-settings core
I am working with a custom MVC PHP framework and the index page (acting
I am using PHP Yii Framework with MongoDB(yiimongodbsuite). I have created a Model which

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.