0

I am trying to use slashes in my url to navigate through my site. So far I can use the first value to call a class (a page), but when I use a second value (after a slash), the page becomes completely messed up and can't call my header.. Well, I hope you get what I mean and maybe help me out.

Here is my Config class, which takes care of the url navigation (mentioned above): http://pastebin.com/38rmh9U1

The url[0] calls a class, but when I add another slash at the end of my url, the header class can't be called.

And this is what I have in my .htaccess file:

RewriteEngine On

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

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

Btw. I am not very strong in what should be in the .htaccess file, but I think this is about right.

1 Answer 1

1

You're not clear on what is 'messed up' and what exactly happens to your header.

I assume your PHP is probably working okay. And your .htaccess is okay too.

I would guess your problem lays in HTML/CSS, where the included header stuff is probably trying to load css/javascript/images/stuff from the wrong directory.

Example, let's say I visit:

http://yoursite.com/home/someValue

And the page loads, and I get the HTML back. And let's say this HTML contains

<script type='text/javascript' src='js/scripts.js'></script>

Then your browser will try to get

http://yoursite.com/home/js/scripts.js

which is probably not the correct url for it.

To fix this, use some kind of baseurl, or always use urls based on the root (eg starting with a slash):

<script type='text/javascript' src='/js/scripts.js'></script>
Sign up to request clarification or add additional context in comments.

1 Comment

I used a define() variable, containing the baseurl. It works perfect now. thanks for your help :)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.