Reputation: 704
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.
Upvotes: 0
Views: 2572
Reputation: 1
In my opinion you should insert: base URL element in your document headers, with your url domain in it. In this way you dont absolutely need to change every path to stylesheet in each file.
<base href="https://www.yourdomain.name/">
Upvotes: 0
Reputation: 64429
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.
Upvotes: 1
Reputation: 1024
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
Upvotes: 3