Mod_Rewrite breaking javascript includes

Mod_Rewrite breaking javascript includes

am 22.08.2007 01:11:18 von johnhutch

I'm trying to use the lightbox photo display at http://kangaroodrake.johnhutch.com/products/.
However, when the rewrite engine is on, my javascript stops
functioning. Without it on, the script works fine. I suspect that my
RewriteRules are messing with the browser's ability to read the .js
files, but I'm not sure how to solve the problem. I tried putting
an .htaccess file in /js/ with RewriteRule off to no avail.

My mod_rewrite is as follows:

1 Options +FollowSymLinks
2 RewriteEngine off
3
4 RewriteRule (^|/)\.svn(/|$) - [F]
5 RewriteRule (^|/)classes(/|$) - [F]
6
7 RewriteRule ^about$ /about/ [R]
8 RewriteRule ^about/$ /index.php?content=about [QSA,L]
9 RewriteRule ^contact$ /contact/ [R]
10 RewriteRule ^contact/$ /index.php?content=contact [QSA,L]
11 RewriteRule ^find$ /find/ [R]
12 RewriteRule ^find/$ /index.php?content=find [QSA,L]
13
14 RewriteRule ^$ /index.php [QSA,L]
15
16 RewriteRule ^(product|products|line|lines)$ /$1/ [R]
17 RewriteRule ^(product|products|line|lines)/$ /index.php?model=
$1&view=index [QSA,L
]
18
19 RewriteRule ^(product|products|line|lines)/([a-z]*)$ /$1/$2/
[R]
20 RewriteRule ^(product|products|line|lines)/([a-z]*)/$ /
index.php?model=$1&view=$2
[QSA,L]
21
22 RewriteRule ^(product|products|line|lines)/([a-z]*)/([0-9]+)$ /
$1/$2/$3/ [R]
23 RewriteRule ^(product|products|line|lines)/([a-z]*)/([0-9]+)/
$ /index.php?model=$1
&view=$2&id=$3 [QSA,L]

Any suggestions?

Re: Mod_Rewrite breaking javascript includes

am 22.08.2007 03:39:27 von HansH

"johnhutch" schreef in bericht
news:1187737878.659095.325610@x35g2000prf.googlegroups.com.. .
> I'm trying to use the lightbox photo display at
> http://kangaroodrake.johnhutch.com/products/.
> However, when the rewrite engine is on, my javascript stops
> functioning. Without it on, the script works fine. I suspect that my
> RewriteRules are messing with the browser's ability to read the .js
> files, but I'm not sure how to solve the problem. I tried putting
> an .htaccess file in /js/ with RewriteRule off to no avail.
Grabbing a line like

from the source of /index.php?content=about shows the scripts are referenced
by releative links. These relative links break if the same content is
addressed as /about/: the browser will request for /about/js/prototype.js
rather than /js/prototype.js.

Mot likely just changing [all] those links to

will save the [next] day.

> My mod_rewrite is as follows:
> 1 Options +FollowSymLinks
> 2 RewriteEngine off
> 4 RewriteRule (^|/)\.svn(/|$) - [F]
> 5 RewriteRule (^|/)classes(/|$) - [F]
What's your intend on those two rules ???

I've made some rearrangements to the rule starting at line 7:
- rules are reordered in descending order of probalility
most request swill now abandon the chain of rewrites after appliing just
only 1 rule, only the site index will take 5
- conditions are collapsed by making the trailing back-slash optional
reducing the count of rules applied
- same applies to the trailing s on some folder names
again reducing the count of rules applied

23 RewriteRule ^(products?|lines?)/([a-z]*)/([0-9]+)/?$
/index.php?model=$1&view=$2&id=$3 [QSA,L]
20 RewriteRule ^(products?|lines?)/([a-z]*)/?$ /index.php?model=$1&view=$2
[QSA,L]
17 RewriteRule ^(products?|lines?)/?$ /index.php?model=$1&view=index
[QSA,L]
8 RewriteRule ^(about|content|find)/?$ /index.php?content=$1 [QSA,L]
14 RewriteRule ^$ /index.php [QSA,L]

HansH

Re: Mod_Rewrite breaking javascript includes

am 22.08.2007 04:45:57 von johnhutch

On Aug 21, 9:39 pm, "HansH" wrote:
> "johnhutch" schreef in berichtnews:1187737878.659095.325610@x35g2000prf.googlegroup s.com...> I'm trying to use the lightbox photo display at
> >http://kangaroodrake.johnhutch.com/products/.
> > However, when the rewrite engine is on, my javascript stops
> > functioning. Without it on, the script works fine. I suspect that my
> > RewriteRules are messing with the browser's ability to read the .js
> > files, but I'm not sure how to solve the problem. I tried putting
> > an .htaccess file in /js/ with RewriteRule off to no avail.
>
> Grabbing a line like
>
> from the source of /index.php?content=about shows the scripts are referenced
> by releative links. These relative links break if the same content is
> addressed as /about/: the browser will request for /about/js/prototype.js
> rather than /js/prototype.js.
>
> Mot likely just changing [all] those links to
>
> will save the [next] day.
>
> > My mod_rewrite is as follows:
> > 1 Options +FollowSymLinks
> > 2 RewriteEngine off
> > 4 RewriteRule (^|/)\.svn(/|$) - [F]
> > 5 RewriteRule (^|/)classes(/|$) - [F]
>
> What's your intend on those two rules ???
>
> I've made some rearrangements to the rule starting at line 7:
> - rules are reordered in descending order of probalility
> most request swill now abandon the chain of rewrites after appliing just
> only 1 rule, only the site index will take 5
> - conditions are collapsed by making the trailing back-slash optional
> reducing the count of rules applied
> - same applies to the trailing s on some folder names
> again reducing the count of rules applied
>
> 23 RewriteRule ^(products?|lines?)/([a-z]*)/([0-9]+)/?$
> /index.php?model=$1&view=$2&id=$3 [QSA,L]
> 20 RewriteRule ^(products?|lines?)/([a-z]*)/?$ /index.php?model=$1&view=$2
> [QSA,L]
> 17 RewriteRule ^(products?|lines?)/?$ /index.php?model=$1&view=index
> [QSA,L]
> 8 RewriteRule ^(about|content|find)/?$ /index.php?content=$1 [QSA,L]
> 14 RewriteRule ^$ /index.php [QSA,L]
>
> HansH

Wow, thank you so much Hans! This helped immensely. To answer your
question, those two lines are merely to keep people out of my
subversion directory and my directory containing my php class
definitions. Though I think, perhaps, your focus on efficiency leads
me to believe that I'd be better off forbidding these folders
with .htaccess files within them.

Re: Mod_Rewrite breaking javascript includes

am 22.08.2007 06:57:51 von johnhutch

On Aug 21, 9:39 pm, "HansH" wrote:
> "johnhutch" schreef in berichtnews:1187737878.659095.325610@x35g2000prf.googlegroup s.com...> I'm trying to use the lightbox photo display at
> >http://kangaroodrake.johnhutch.com/products/.
> > However, when the rewrite engine is on, my javascript stops
> > functioning. Without it on, the script works fine. I suspect that my
> > RewriteRules are messing with the browser's ability to read the .js
> > files, but I'm not sure how to solve the problem. I tried putting
> > an .htaccess file in /js/ with RewriteRule off to no avail.
>
> Grabbing a line like
>
> from the source of /index.php?content=about shows the scripts are referenced
> by releative links. These relative links break if the same content is
> addressed as /about/: the browser will request for /about/js/prototype.js
> rather than /js/prototype.js.
>
> Mot likely just changing [all] those links to
>
> will save the [next] day.
>
> > My mod_rewrite is as follows:
> > 1 Options +FollowSymLinks
> > 2 RewriteEngine off
> > 4 RewriteRule (^|/)\.svn(/|$) - [F]
> > 5 RewriteRule (^|/)classes(/|$) - [F]
>
> What's your intend on those two rules ???
>
> I've made some rearrangements to the rule starting at line 7:
> - rules are reordered in descending order of probalility
> most request swill now abandon the chain of rewrites after appliing just
> only 1 rule, only the site index will take 5
> - conditions are collapsed by making the trailing back-slash optional
> reducing the count of rules applied
> - same applies to the trailing s on some folder names
> again reducing the count of rules applied
>
> 23 RewriteRule ^(products?|lines?)/([a-z]*)/([0-9]+)/?$
> /index.php?model=$1&view=$2&id=$3 [QSA,L]
> 20 RewriteRule ^(products?|lines?)/([a-z]*)/?$ /index.php?model=$1&view=$2
> [QSA,L]
> 17 RewriteRule ^(products?|lines?)/?$ /index.php?model=$1&view=index
> [QSA,L]
> 8 RewriteRule ^(about|content|find)/?$ /index.php?content=$1 [QSA,L]
> 14 RewriteRule ^$ /index.php [QSA,L]
>
> HansH

Hans, this fixed everything beautifully save one detail: my css file
refuses to include any images. Anything referenced by url(/images/
image.jpg) or url(image.jpg) or url(/css/image.jpg) or any variant of
absolute or relative links is broken. Any experience with this?

Re: Mod_Rewrite breaking javascript includes

am 23.08.2007 00:00:36 von HansH

"johnhutch" schreef in bericht
news:1187750757.152862.205860@r23g2000prd.googlegroups.com.. .
>> > My mod_rewrite is as follows:
>> > 1 Options +FollowSymLinks
>> > 2 RewriteEngine off
>> > 4 RewriteRule (^|/)\.svn(/|$) - [F]
>> > 5 RewriteRule (^|/)classes(/|$) - [F]
>>
>> What's your intend on those two rules ???
>>
> ... those two lines are merely to keep people out of my
> subversion directory and my directory containing my php class
> definitions.
It's the syntax that bothers me most.
(^|... means 'begins with nothing or ...' sound quiet silly

> Though I think, perhaps, your focus on efficiency leads
> me to believe that I'd be better off forbidding these folders
> with .htaccess files within them.
Confirmed and then suggesting
Order Deny,Allow
Deny from all
is by far the easiest way to shut each door.

However, if you have access to the folder one level closer to the root, just
park both folders there OUT OF Apache's SIGHT and thus invisible for the
public.

HansH

Re: Mod_Rewrite breaking javascript includes

am 23.08.2007 00:43:16 von HansH

"johnhutch" schreef in bericht
news:1187758671.812295.289460@e9g2000prf.googlegroups.com...
>> >http://kangaroodrake.johnhutch.com/products/.

> ... this fixed everything beautifully save one detail: my css file
> refuses to include any images. Anything referenced by url(/images/
> image.jpg) or url(image.jpg) or url(/css/image.jpg) or any variant of
> absolute or relative links is broken. Any experience with this?
>
Surprisingly http://www.w3.org/TR/CSS1#url states
'Partial URLs are interpreted relative to the source of the style sheet, not
relative to the document:'

thus _dispite_ the leading slash
#prevLink:hover, #prevLink:visited:hover {
background : url(/images/prevlabel.gif) no-repeat left 15%;
}
will _nevertheless_ request for /css/images/prevlabel.gif.
( Check your access_log ! )

Following the definition changing to
background : url(http://kangaroodrake.johnhutch.com/images/prevlabel.gif)
no-repeat left 15%;
or preferred
background : url(../images/prevlabel.gif) no-repeat left 15%;
should solve the incident.


HansH