mod_rewrite: using it for CSS and JS?

New to mod_rewrite? This is a good place to start.

mod_rewrite: using it for CSS and JS?

Postby vaaaska » Thu May 12, 2005 2:40 am

On my test machine this works...but I don't know how feasible this is.

I'm taking the entire URI returned by mod-rewrite and looking up documents in a mysql database. It grabs the contents and then inserts them into the template. It's working flawlessly.

The other thing that works, because I throw a switch if the document ends with .css or .js, is that I can include files in my html page.

Code: Select all
<link rel="stylesheet" href="/css/style.css" type="text/css" />
<script type='text/javascript' src='/js/script.js'></script>

These too come straight out of the database - so in effect I'm calling up three pages from the database when the user visits the site. Certainly, there are server use issues, but I'm sort of foregoing that part of things for the moment.

But, I don't really know how feasible this would be for greater use?
Posts: 7
Joined: Thu May 05, 2005 5:45 pm

Postby vaaaska » Wed May 25, 2005 7:01 am

Aside from just doing it...I'm still very curious if there is any kind of technical explanation about this.

I'm about to release an open source cms to the public at large and this is one of the last things I'm still thinking about. I can't really find any decent explations...

Posts: 7
Joined: Thu May 05, 2005 5:45 pm

Postby Caterham » Tue May 31, 2005 12:03 pm

if there is any kind of technical explanation about this.
In which way?

You should keep in mind, that PHP doesn't send an ETag/Last Modified since header

HTTP-Response wrote:HTTP/1.x 200 OK
Date: Tue, 31 May 2005 19:52:55 GMT
Server: Apache/1.3.31 (Unix) PHP/4.3.10
Last-Modified: Tue, 31 May 2005 19:11:01 GMT
Etag: "7008c9a-10194-429cc061"
Accept-Ranges: bytes
Content-Length: 65940
Connection: close
Content-Type: text/html

Re-request by browser wrote:GET / HTTP/1.1
If-Modified-Since: Tue, 31 May 2005 19:11:01 GMT
If-None-Match: "7008c9a-10194-429cc061"

HTTP-Response Not Modified wrote:HTTP/1.x 304 Not Modified
Date: Tue, 31 May 2005 19:52:56 GMT
Server: Apache/1.3.31 (Unix) PHP/4.3.10
Connection: close
Etag: "7008c9a-10194-429cc061"

And this is missing for dynamical generated documents (if your Script doesn't generate such headers and checks the Requestheaders, too).

Take also a look on
Posts: 690
Joined: Fri Dec 10, 2004 1:30 pm

Postby Deliriumxx » Thu Feb 04, 2010 6:59 pm

I have been trying to start a thread with a question and I am not sure if this is similar or not but I figured,, I can ask here... (apparently I need to be invited to be allowed o post ??)

I have a folder on the site that requires authorized access. The code I use for that is

Code: Select all
AuthUserFile /path/to/.htpasswordfile
AuthType Basic
AuthName "My Site Hello"

require valid-user

However there are 3 images within the protected folder that request my members to RE enter authorization info 3 extra times (I suppose for each image) until they can peacefully enter the protected area.

I tried adding this

Code: Select all
<Directory "/subdirectory_in_protected_directory">
  AllowOverride AuthConfig
  Order allow,deny
  Allow from all

I played with trailing slashes as well, but no luck.

I am a complete idiot for this stuff! Can you guys help me out a little with this?

The header shows a 304 error thingy.
Posts: 13
Joined: Fri May 12, 2006 8:34 pm

Return to Beginner's Corner

Who is online

Users browsing this forum: No registered users and 9 guests