Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Undefined URL with multiple subfolders 404 Problem #68

Open
hkZeneus opened this issue Jun 27, 2024 · 1 comment
Open

Undefined URL with multiple subfolders 404 Problem #68

hkZeneus opened this issue Jun 27, 2024 · 1 comment

Comments

@hkZeneus
Copy link

Good evening!

First of all i'm really greatful for this library, saves a lot of time and effort!

To recreate the problem I'm having, try accessing the URL: localhost/xxx/yyy/zzz
I have not set a route for this, so it should redirect to 404.
It does in fact redirect to 404, but the CSS/JS files I import into the project are always parsed as href="xxx/yyy/path/to/CSSorJS".
is there a way to patch this other than adding a for loop to add "../" for every layer of the URL -1?

url
error

Thanks in advance and kudos for the great work!

@Shermalc
Copy link

Shermalc commented Sep 3, 2024

When routing files, you're always going to mess up the paths for dependencies, unless the router was designed to deal with this problem.
I have overcome this with assigning a permanent path to the CSS or JS

<?php
$basedir = '/phprouter';
?>
<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
  <link rel="stylesheet" href="<?= $basedir.'/' ?>assets/style.css">
</head>

if your in public_html folder, then `$basedir='/';

Hope this helps :-)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants