![]() |
Whats with the weird external stylesheet links?
Okay... Please share the secret. Why and how do they do this:
<link rel="stylesheet" type="text/css" media="all" href="http://<snip>.com/?css=styles/index.v.1195440872" /> and also, whats with the W3C.... How did they make a stylesheet do this: http://www.w3.org/StyleSheets/TR/W3C-WD They just link to the directory and it goes to the stylesheet. I feel violated. This goes against everything I was taught in elementary school! |
As to your first question, are you asking about the link tag or the way the script linked returns the CSS? It appears to be a relatively generic script receiving a GET string, processing it and returning a stream of CSS to be included in the document.
The W3C, I'm not positive, but I think the 'W3C-WD' is the stylesheet. It just doesn't have the .css extension. |
The way the script returned the CSS, and why it was used that way.
|
Quote:
Code:
<?php |
For the CSS file with a versioning string, it's simply to make sure that when a new version of the CSS file is uploaded people can immediately see the changes (because the URL will change) since the cache won't be made for that particular URL. A simple solution would be to load in the specified CSS file (using Apache, PHP, etc.) or a default one if it does not exist (or 404 ;)).
With the stylesheet on the W3C site, the correct file will show up because their web server is using Content Negotiation (Apache). Full details are at the 'Apache' link just posted, but essentially (depending how you have things set up) Apache will look for files in that location and deliver the best match, if any. For example, on my local server I can access http://localhost/mydir/myfile which might call a PHP script if there is a myfile.php available. If I created a myfile.html and accessed the same URL, the displayed page would be the HTML document because that overrules the PHP file. If I got rid of the HTML and PHP file but instead placed a myfile.png there, the same URL would display the image. (Note: This is not mod_rewrite!)If you try to access http://www.w3.org/StyleSheets/TR/W3C-WD.css then you'll get the stylesheet. If you try instead to access http://www.w3.org/StyleSheets/TR/W3C-WD.html, you'll get a 300 Multiple Choices header with in this case a list of available files. |
I used a similar method, to allow quick access to editing the CSS from the database. I just used a text/css header in PHP and outputted the CSS.
Same thing goes with RoR, look at: Code:
<link href="http://asset2.projectpath.com/stylesheets/cache/all.css?1207968108" media="screen" rel="stylesheet" type="text/css" /> |
Wouldn't you have to link to a .php file? I mean, linking to .css would lead you to a file not there, but linking to a .php file would give you a css file, wouldn't it?
|
mod Rewrite :)
|
mod rewrite is overrated and queer.
|
I do admit that mod_rewrite's syntax is a bit odd but it's dead useful.
|
useful for what?
|
A LOT.
Code:
RewriteRule ^users/info/([A-Za-z0-9_]+)/?$ users/info.php/$1mod_rewrite is damned cool, IMHO. -m |
yea mod_rewrite can be used for alot, a few of my favorites is getting myspace to post some dynamic images on my site, since they block .php extensions in files
its good for SEO, since google and other sites thing page.php?id=1 and page.php?id=2 is the same page if you wanted forums and such to get crawled youd need a modrewrite to make page-1.php and page-2.php although id make that prettier. This site even uses it for SEO |
You're wrong. Google understands dynamic links. There's no need to respond to this thread anymore unless you have something important to say about dynamic stylesheet links. This isn't about mod_rewrite.
However, thanks for all of your help :P |
Whoah, somebody had a bad date with mod_rewrite. Why all the hostility?
Google understands them, google just doesn't care for them. So if you want to rank higher, you won't use dynamic links. Plus, if you want your site to be more user-friendly, you won't use them. Plus, if you want your site to be a little more secure from front-door attacks, you won't use them. Plus, I could go on forever. Have you ever once had a conversation in person that didn't start on one topic and end on another? Relax. ;-) -m |
All the hostility is as soon as I put in
Code:
RewriteEngine onedit: just turned on the rewrite module. Now my problem is the weird regex that I have to learn. |
Are you running a test machine that does that, or is it on a remote host? Because it sounds to me like the module just isn't loaded in - for some stupid reason mod_rewrite is shipped with apache but not turned on (well, I think it's stupid). If you're on your own box, you can open up httpd.conf and edit this line:
And then as long as allowoverrides is on, you can mod_rewrite to your hearts content. If your host doesn't have it on however, like I just discovered (#@$@#$@) then you may be outta luck. Which is why I wish Apache had it turned on by default, because then my host probably would too, and I could happily use it while they sat in their nice little air conditioned offices thinking they was the shiznit. -m |
After loading the module, reboot your apache server.
|
Quote:
|
| All times are GMT. The time now is 07:35 PM. |
Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0