rewrite "../../dirname"

Using a single web hosting account to host multiple sites

rewrite "../../dirname"

Postby mutex » Thu Mar 29, 2007 8:21 am

Hi,

This is kind of weird to explain, I apologize if its difficult to follow.

Im a sysadm for a University website and I have a prob with the way some of our vhosts are setup. An example is the html source on one of the vhost sites refers to 2 directories, one is "images" and the other is "../../images". I would like to match the "../../images" folder but not "./images".

To make matters worse, the html is already at the top level that's trying to call "../../images". Obviously it cant go 2 directories up when your already at the top level. This was caused by having a website like www.domain.edu/acm/dept/sci/bio/user1 and then a vhost bio.domain.edu/user1 pointing to the same directory. The website had a /index.html that had relative links like ../../style/style.css and obviously that wont work on the vhost site. I know I can use abolsute links etc, but its ALOT of html to rewrite, and this issue keeps coming up.

I tried:
RewriteCond %{REQUEST_URI} \.\.\/\.\.\/images\/.*
and:
RewriteCond %{THE_REQUEST} \.\.\/\.\.\/images\/.*

But the rewrite log shows it tries to match "/images", not "../../images".

Is there a way to do this?? I will give you my firstborn if you help me fire this out.

Thanks!
Dan
mutex
 
Posts: 2
Joined: Wed Mar 28, 2007 2:24 pm

Postby richardk » Fri Mar 30, 2007 12:09 pm

Mod_rewrite doesn't edit the HTML, it only works on the incoming request. The ../ will be translated by the browser into a real path and not sent to the server. When i tried a HTML file with ../../../abc.gif in my document root, Firefox requested /abc.gif. What is the path of a bad incoming request? That's what you need to match.
richardk
 
Posts: 8800
Joined: Wed Dec 21, 2005 7:50 am

Postby mutex » Sat Mar 31, 2007 9:08 pm

The more I look into it, the more I think mod_rewrite, nor any other apache fix or reconfiguration is going to work. Your right, I wasnt able to get ../../link with mod_rewrite either, just the full path it refers to. Thank you for looking into it though.

Unfortunatly there's so many links with this problem that I cant match them individually. I was trying to avoid fixing the html with perl/sed because there's gigs and gigs of this stuff, and it keeps being uploaded, but I dont think I have a choice.

Im going to try the apache users mailing list, maybe someone has run into this problem before and can suggest something. If nothing else ive learned alot about how mod_rewrite works, and that will always come in handy!

Dan
mutex
 
Posts: 2
Joined: Wed Mar 28, 2007 2:24 pm

Postby richardk » Sun Apr 01, 2007 1:45 pm

You could redirect requests to the type of the URL that's broken to the other.
richardk
 
Posts: 8800
Joined: Wed Dec 21, 2005 7:50 am


Return to Domain Handling

Who is online

Users browsing this forum: No registered users and 90 guests

cron