|
Home > Archive > Unix administration > March 2007 > rewrite ../../ with mod_rewrite
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
rewrite ../../ with mod_rewrite
|
|
|
| Hi,
I was wondering if anyone knew of a way to get apache to rewrite
"../../"
An example of my problem:
Say I have a economics website at
www.domain.edu/academics/departments/sites/economics. The users want a
subdomain that points to the site. I add econ.domain.edu and set the
DocumentRoot to
/var/www/html/academics/departments/sites/economics
So far no prob....
However, the file econ.umb.edu/index.html has links to "../../images"
AND links to "./images". Because it was originally written at
www.umb.edu it worked, but once you redefine the DocumentRoot with the
virtual host it wont work. You cant goto ../../images when your
already
at the top level.
I discovered I can alias things outside the DocumentRoot but because
there's 2 directories with the same name that wont work here.
I tried using mod_rewrite to match on "../../images" but when looking
at
the rewrite log it doesnt see a difference between "../../images" and
"./images" when using the virtual host. They both get requested as
"/images", when at the top level the server automatically chops the
"../../" away.
Any ideas? Of course we can rewrite the html with absolute links, or
rename things, but because of the way webdevelopers did things around
here, its alot of rewriting. If it was just the images directory
that'd be one
thing, but of course it happens with many different directory names
over
thousands of pages of html.
Thanks
Dan
| |
| Dave Hinz 2007-03-30, 7:19 pm |
| On 30 Mar 2007 10:32:53 -0700, Dan <mutex77@yahoo.com> wrote:
> Hi,
>
> I was wondering if anyone knew of a way to get apache to rewrite
> "../../"
Why?
> An example of my problem:
> Say I have a economics website at
> www.domain.edu/academics/departments/sites/economics. The users want a
> subdomain that points to the site. I add econ.domain.edu and set the
> DocumentRoot to
> /var/www/html/academics/departments/sites/economics
> So far no prob....
Right.
> However, the file econ.umb.edu/index.html has links to "../../images"
Shouldn't work. Apache shouldn't let you up beyond your document_root.
> AND links to "./images". Because it was originally written at
> www.umb.edu it worked, but once you redefine the DocumentRoot with the
> virtual host it wont work. You cant goto ../../images when your
> already
> at the top level.
They need to fix their links.
> Any ideas? Of course we can rewrite the html with absolute links, or
> rename things, but because of the way webdevelopers did things around
> here, its alot of rewriting.
A sed script would do nicely.
> If it was just the images directory
> that'd be one
> thing, but of course it happens with many different directory names
> over
> thousands of pages of html.
Breaking your webserver to serve their broken HTML isn't really the
right solution. Sets a bad precedent if nothing else.
| |
|
| On Mar 30, 7:55 pm, Dave Hinz <DaveH...@gmail.com> wrote:
> On 30 Mar 2007 10:32:53 -0700, Dan <mute...@yahoo.com> wrote:
>
>
>
> Why?
>
>
> Right.
>
>
> Shouldn't work. Apache shouldn't let you up beyond your document_root.
>
>
> They need to fix their links.
>
>
> A sed script would do nicely.
>
>
> Breaking your webserver to serve their broken HTML isn't really the
> right solution. Sets a bad precedent if nothing else.
Hi,
I agree, Its a total hack. However, this isnt a regular web
development team, its very non-technical faculty at a large state
university. They dont even know what html is, they use Adobe's
Contribute to change their web pages without any knowledge of the
underlying technologies. Many of our users dont understand how to send
mail attachments, nevermind editing html. Making the users smarter
wont work in this case. Most are too far gone and there's way too many
of them.
I have used PERL & sed to do mass html replacements, but the website
is HUGE, with over 10 years of junk faculty & staff has uploaded. A
simple 4 line PERL script takes over 12 hours to chew through all the
web pages on these ancient servers. The next day the users will have
uploaded the more and more examples of the problem. Ive thought about
nightly "html fixing" cronjobs, or fixing the html as they upload it.
Adding a few lines with mod_rewrite seemed alot easier, but it doesnt
seem like it can be done. I figured i'd ask tho.
Dan
|
|
|
|
|