Welcome to WebmasterWorld Guest from 34.204.203.142

Forum Moderators: Ocean10000 & phranque

Message Too Old, No Replies

Keeping users in a directory with mod_rewrite?

Creating a browsable intranet archive.

     
4:59 pm on Dec 10, 2003 (gmt 0)

New User

10+ Year Member

joined:Dec 10, 2003
posts:2
votes: 0


Ok, first post here, I hope you guys can help!

I'm in the middle of moving our intranet site from IIS to Apache. Everything's working fine with that. This is part of a major site-wide update.

However, the client has asked me to make a broswable snapshot of the current site, and make it available under "http://intranet/archive/" Fine. Easy enough.

The problem is this:

When browsing http://intranet/archive, most of the links are written as http://intranet/path/to/file, or just /path/to/file.

Because of this, the archive is not browsable, since the links in the archive will take the user to links in the live site. Even creating this as a virtual host will not fix the ones that actually specify the client.

So here's my question: How do I keep people in the archive directory once they're there? I was thinking of using mod_rewrite and the HTTP_REFERER condition, but I can't seem to figure out how to make that work. Perhaps a perl script or something that'll figure it out for me? I don't quite know how I'd go about that either.

So, any help here? Thanks a lot.

[edited by: jdMorgan at 4:55 pm (utc) on Dec. 11, 2003]
[edit reason] De-linked [/edit]

4:22 am on Dec 11, 2003 (gmt 0)

Senior Member

WebmasterWorld Senior Member jdmorgan is a WebmasterWorld Top Contributor of All Time 10+ Year Member

joined:Mar 31, 2002
posts:25430
votes: 0


CHRYSt,

Welcome to WebmasterWorld [webmasterworld.com]!

mod_rewrite works in the time between when a request is received and when the requested content is sent back. Therefore, you can't 'keep' anyone in the archive if they click on a link that takes them out. All you can do is redirect from the new site back into the archive if you recognize a URL that belongs to the archive.

If you set up new directories with unique names for the new site (so you can tell new-site URLs from old-archive URLs), this might be do-able.

Jim

2:43 pm on Dec 11, 2003 (gmt 0)

New User

10+ Year Member

joined:Dec 10, 2003
posts:2
votes: 0


Hey sweet. I went and got it working:

Simple enough too, once I stopped trying to over-think it.

In case anyone's interested:

Basically, if they're they're already IN the archive, and they request a file that's not in the archive, it redirects them to the same filename except with /archive/ in front.

RewriteCond %{HTTP_REFERER} ^http://intranet(.*)/archive(.*)$
RewriteCond %{REQUEST_FILENAME} !^/archive(.*)$
RewriteRule ^/(.*) http://intranet/archive/$1 [R]

[edited by: jdMorgan at 4:54 pm (utc) on Dec. 11, 2003]
[edit reason] De-linked [/edit]