...

View Full Version : Mod Rewrite Turns Off CSS



Joseph Witchard
04-28-2010, 04:29 AM
Go to http://www.hogwarts-rpg.net/category_news.php?name=Rebirth_News&id=3. Now, access the same page via the rewritten URL at http://www.hogwarts-rpg.net/category_news/Rebirth_News/3. See how nothing seems to be styled on the page that time around? What's up with that?

My mod_rewrite code for the page is:


RewriteRule ^category_news/([a-zA-Z_]+)/([0-9]+)$ /category_news.php?name=$1&id=$2

abduraooft
04-28-2010, 09:15 AM
Take a look at http://www.codingforums.com/showthread.php?t=158883

Joseph Witchard
04-29-2010, 03:30 AM
I don't get it. How does using absolute paths solve the problem? Indeed it does, but how?

Samhain13
04-29-2010, 12:35 PM
The user-agent thinks that it's getting resources from hogwarts-rpg.net/category_news/Rebirth_News/3, a directory that really doesn't exist. So if you have links for your CSS that are relative, like "mycssfile.css", the user-agent sends a request for "hogwarts-rpg.net/category_news/Rebirth_News/3/mycssfile.css" file.

However, when using an absolute URI like "/mycssfile.css", the user-agent requests a file relative to the document root (public_html (?)) folder. So it knows that the file's address is "hogwarts-rpg.net/mycssfile.css". And it works if the file is really in that directory.

Err... sorry if that wasn't clear. :D

Joseph Witchard
04-30-2010, 07:10 AM
The user-agent thinks that it's getting resources from hogwarts-rpg.net/category_news/Rebirth_News/3, a directory that really doesn't exist. So if you have links for your CSS that are relative, like "mycssfile.css", the user-agent sends a request for "hogwarts-rpg.net/category_news/Rebirth_News/3/mycssfile.css" file.

However, when using an absolute URI like "/mycssfile.css", the user-agent requests a file relative to the document root (public_html (?)) folder. So it knows that the file's address is "hogwarts-rpg.net/mycssfile.css". And it works if the file is really in that directory.

Err... sorry if that wasn't clear. :D

No no, you explained it well:) So it's the /s in the rewritten URL that are causing the problems, right? It's making it think it's a directory?

abduraooft
04-30-2010, 07:55 AM
So it's the /s in the rewritten URL that are causing the problems, right? It's making it think it's a directory? Yes, absolutely!



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum