0

I have a website that has an index.php, a few simple .html pages and one .php page (contact form) as well as a .htaccess file. On my website I have buttons that point to the pages as follows: index.php?p=welcome.php (example). As you can see, the index.php file includes a page, depending on what was passed on by GET.

I've written the .htaccess to show: http://www.site.com/welcome/ instead of http://www.sites.com/index.php?p=welcome. The links and rewrite both work. The only problem I have is when I click one of the buttons to navigate to another page: there is no styling whatsoever.

I've tested to see if the index.php file is including the other pages properly, and it does. It's just the stylesheet that doesn't seem to work. The style.css is included at the top of the index.php file, where it belongs. Here are bits of code I'd like to show you:

Buttons

<table>
    <tr>
        <td><a href="/welcome/"><div>Welcome</div></a></td>
    </tr>
    <tr>
        <td><a href="/references/"><div>References</div></td></a>
    </tr>
    <tr>
        <td><a href="/aboutme/"><div>About me</div></td></a>
    </tr>
    <tr>
        <td><a href="/contact/"><div>Contact</div></td></a>
    </tr>
</table>

.htaccess

RewriteEngine On
RewriteRule ^([a-z]+)/$ index.php?p=$1

To make it clear: the site still functions as it normally does, but it just does not apply any styling from the stylesheet. Any help would be much appreciated.

2
  • When you navigate to a seperate page, is any of the index.php source involved in the second page, or is this a clean page(redirect)? Jan 4, 2011 at 16:46
  • Whats the Url for stylesheets ? is it index.php?p=style.css ? or thats a Plain url ?
    – Neel Basu
    Jan 4, 2011 at 16:46

2 Answers 2

3

If the stylesheet is being included using a relative path, then that would be the problem. Try using: /path/to/style.css rather than relative/path/to/style.css

So if your stylesheet lives in templates/style.css and you reference it as such, when you rewrite the URL http://www.site.com/index.php?page=welcome to http://www.site.com/welcome/, the stylesheet's path is relative to that:

http://www.site.com/welcome/templates/style.css

1
  • That's it. I'm including the stylesheet using a relative path: <link type="text/css" href="style.css" rel="stylesheet" />. I've changed it to: /style.css and now it works perfectly. I guess I still have to learn some more. Thank you.
    – Fusyion
    Jan 4, 2011 at 16:54
1

You might be including it with a relative path? When your'e using ./ you are trying to include something from the new (non excistent?) /welcome dir.

Try to include your stuff trough the complete path, or use some sort of variable that tells you the real basepath.

0

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.