Problem with trailing slash

43 views
Skip to first unread message

Leo Zurbriggen

unread,
Feb 22, 2013, 4:46:57 AM2/22/13
to limo...@googlegroups.com
Hello everyone

I have a little problem when loading css files etc.

I load a php-Page by with dispatch('/testpage', 'getTestpage'); and require my page in the getTestpage function.
Now I request a css file in my page, like this: <link rel="stylesheet" href="css/styles.css"/>

For testing purposes, I implemented this:

dispatch('**/*.css', 'getCSS');
function getCSS() {
    echo request_uri();
}

Now, I type in my url in the browser:

-> I get /testpage/css/styles.css

If I don't type the slash: http://localhost/testpage

-> I get /css/styles.css

I expect to get the same URL in both cases. Am I doing something wrong?

Thanks in advance
Leo

Fabrice Luraine

unread,
Mar 11, 2013, 1:21:34 PM3/11/13
to limo...@googlegroups.com
Hello,

this is normal, you declared your css path in a relative way, so it depends of the page url. You'd better use absolute path for your assets and store them in the public directory, no need to write routes

    <link rel="stylesheet" href="/public/css/styles.css"/>
Reply all
Reply to author
Forward
0 new messages