Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

mod_rewrite with javascript frameset

Status
Not open for further replies.

paulx82

Technical User
Feb 11, 2002
21
AU
Hi all. I have a javascript frameset which I think is screwing up my URLs using mod_rewrite or it may just be my mod_rewrite rule, I'm not sure.

The frameset:

document.write('<frameset id=&quot;TopFrame&quot; rows=&quot;20%,80%&quot; frameborder=&quot;0&quot; framespacing=&quot;0&quot;>');
document.write('<frame scrolling=&quot;no&quot; src=&quot;top.php&quot; name=&quot;top&quot;>');
document.write('<frameset id=&quot;BottomFrame&quot; cols=&quot;21%,79%&quot; frameborder=&quot;0&quot; framespacing=&quot;0&quot;>');
document.write('<frame src=&quot;content_sb.php&quot; name=&quot;left&quot;>');

document.write(&quot;<frame src=' + &quot;<?php echo $SERVER_NAME; ?>&quot; + &quot;/&quot; +

(location.search?location.search.substring(1):'content.php') + &quot;' name='right'>&quot;);

document.write('</frameset>');


Using the rule:
RewriteRule content-(.*)-(.*)-(.*)\.php$ /content\.php?category_id=$1&subcategory_id=$2&item_id=$3

with a URL such as:

Everything works fine. The page doesn't open in the frameset, but that is what it's supposed to do.


with a URL such as:

Everything works fine. The page opens in the frameset as it is supposed to do.


What I want is a rewrite rule that maps to

so the page opens in the correct frame of the frameset.


I have tried the following rewrite rule:
RewriteRule content-(.*)-(.*)-(.*)\.php$ /index2\.php?content\.php?category_id=$1&subcategory_id=$2&item_id=$3

but it doesn't work for some reason, the page in the right frame ends up being &quot;content.php&quot; (location.search doesnt exist), either because of the javascript frameset or just the rewrite rule.

Could you please help me with this?
Thanks.

The discipline used to write things down is the first step in making them a reality.
 
If your getting the javascript error 'location.search doesnt exist' then it sounds like your problem is before rewrite even gets a hold of it. I would look there first.
 
Hi siberian. I think you may be right about it being a mod_rewrite problem only. I forgot to mention before that I am running Apache 2.0.48 on Windows XP. I tried a few different rewrite rules including:

RewriteRule content-([^-]*)-([^-]*)-([^-]*)\.php$ /index2\.php?content\.php?category_id=$1&subcategory_id=$2&item_id=$3 [QSA,L]

but still no luck. I've also turned AcceptPathInfo on in my httpd.conf and turned MultiViews off, because apparently they can cause problems. I'm no expert with mod-rewrite, but maybe the log of &quot;mod_rewriting&quot; will makes some sense to you and you'll be able to help me with a solution, if you would be so kind.

(2) init rewrite engine with requested uri /content-2-8-77.php
(3) applying pattern 'content-([^-]*)-([^-]*)-([^-]*)\.php$' to uri '/content-2-8-77.php'
(2) rewrite /content-2-8-77.php -> /index2.php?content.php?category_id=2&subcategory_id=8&item_id=77
(3) split uri=/index2.php?content.php?category_id=2&subcategory_id=8&item_id=77 -> uri=/index2.php, args=content.php?category_id=2&subcategory_id=8&item_id=77
(2) local path result: /index2.php
(2) prefixed with document_root to C:/Apache2/htdocs/index2.php
(1) go-ahead with C:/Apache2/htdocs/index2.php [OK]

The discipline used to write things down is the first step in making them a reality.
 
I think rewrite is handling it fine, that log seems to indicate this.

I think I mentioned this before, I think your javascript is busted.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top