Forum Moderators: coopster & phranque

Message Too Old, No Replies

Modifying HTML Dynamically

         

geckofuel

2:46 am on Mar 13, 2003 (gmt 0)

10+ Year Member



Perhpas a better title would have been "Reverse Mod-Rewrite"

How would one go about modifying every occurrence of a particular string in HTML dynamically?

Here's what I'm interested in doing.

Say that you've got a bunch of links like the following:

/cgi-bin/cgifile.cgi?file=2&position=7

And you'd like for each occurrence of these links to be modified to read something like this:

/cgi-bin/cgifile/2/7

Is there a way to modify HTML on the fly so that every occurrence of the first type of a link is modified into the format of the second type of link?

If a file has a whole series of the first type of links, is there anyway to filter the serving process so that the second format is substituted for the first?

andreasfriedrich

3:46 am on Mar 13, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



You could write an Apache [httpd.apache.org] module that postprocesses your output. This will be fast but you need to know about the Apache [httpd.apache.org] API. Or have a look at Bag-O-Tricks for PHP II - some code snippets that should be helpful for all in creating dynamic sites - Getting rid of those query strings [webmasterworld.com] for an explanation on how to do it using PHP [php.net].

Andreas

brotherhood of LAN

4:02 am on Mar 13, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Hey andreas, if that thread was an affiliate program you could retire today..all roads lead to.....bag of tricks ;) jk of course....

gecko, is the HTML already on the page, maybe pulled from a db...? If it's in a variable it might be easy-ish to use a little REGEX when needed to strip the query strings you want removed.

Not sure if the REGEX is already in that thread andreas posted, if it isnt, its nearby :)

andreasfriedrich

4:31 am on Mar 13, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



>>all roads lead to.....bag of tricks ;)

Amazing, isnīt it. I have been posting these links quite often lately. Now either those bags are already quite full with nice little scripts or people keep asking the same questions ;).

>>REGEX is already in that thread andreas posted

Yes it is. ;)

BTW good luck with your bio-informatics plans, bol. Are you on your way to become the next Lincoln Stein ;)?

Andreas

brotherhood of LAN

4:47 am on Mar 13, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



not that i want to bring it off topic, but sure, I'd sell him pagerank just so he can be seen on the web ;)