Forum Moderators: phranque

Message Too Old, No Replies

How to make a mod_rewritte condition

         

oscar78

7:36 am on Apr 20, 2005 (gmt 0)

10+ Year Member



Hello,
I have created a .htaccess file to rewrite the URL of a web page and works perfectly.

The .htacces code is the following one:
Options +FollowSymLinks
RewriteEngine on
Rewriterule ^(.*)\.html$ index.php?id=$1

The problem is on a page which includes the following code to load html within iframe:

Code HTML:
< iframe src="_inc/archivo.html" rameborder="0"></iframe >

Apparently, the rules written in the file htaccess modifies "src path" of iframe and it does not load the page, of iframe, correctly.

Somebody can orient to me how to resolve this small problem?
How I Can writte a rule to ignore de iframe source path?

Thank you very much to all!

jdMorgan

5:14 pm on Apr 20, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



oscar78,

Welcome to WebmasterWorld!

> How I Can write a rule to ignore de iframe source path?

You can't, because that is not the cause of the problem.

> Apparently, the rules written in the file htaccess modifies "src path" of iframe and it does not load the page, of iframe, correctly.

No, it is not the rule, it is the browser.

You have provided a relative link to archivo.html. It is the client browser that resolves relative links to canonical URLs. So, the browser still believes it is requesting pages from the original directory, not the rewritten directory. As a result, it will take the page URL it is showing in its address bar, remove everything from the last slash in that URL to the end, and then add "_inc/archivo.html". It will then request that page.

One way to fix this is to create a RewriteRule to reverse the previous rewrite for the iframe page only. Another way to do it is to use a server-relative path instead of a relative path. Something like:


<iframe src=[b]"/path_to_inc_from_root/_[/b]inc/archivo.html" frameborder="0"></iframe>

Note the leading slash. You provide a full path from your Web root (home page) directory to the archivo page. In this way, the browser will know the correct path to the file.

Jim

oscar78

5:25 pm on Apr 20, 2005 (gmt 0)

10+ Year Member



ok jdMorgan. Now works fine!
Thank you for your help!
Bye!