|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| ||||||||||||||||||||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
"Push" single document root URL rewrite also drop file ext.
We have reached our limits here, so hopefuly someone can explain this. We are containing windows .chm helpfile source with unhelpful URLs under a single online navigator. Here is an example of .chm source URL:
Code:
<A HREF="mk:@MSITStore:ITC_IDR.chm::/IDR_LISP_B118.htm"> I have this developed to sanitize, works most of the time: PHP Code:
...where $docroot is a string created by another function to return the URL base of this "content manager". This results in any of the hundreds of HTML source files in directory being callable by name from a single base URL xxx?help=NAME. My problem is twofold: I have another set of HTML source documents parsed from the hhc indexes which actually uses "sane" HTML links which need to be "rewritten" upon display for same behavior as above. I would also like to drop all file extensions that same line as well (more efficient) -- here is the conversion: (match a)|(match b)+(FILENAME)+(extension)= ($docroot)(FILENAME) where a = "mk:@MSITStore:[^<>[:space:]]+[[:alnum:]/]+.chm::/" but b = nothing (these elements look like <a href="filename.htm">) Since we can't search for nothing, probably I actually need to search for all <a> tags and push/replace WHATEVER MIGHT prepend the href's filename with $docroot to PHP buffer: (match href=?)+(FILENAME)+(extension)= ($docroot)(FILENAME) The resulting URLS are always xxx?help=FILENAME (minus extension, and where "xxx?help=" represents what is actually in $docroot) Sorry I don't know how to describe the problem more simply, but I know there is an answer. Can anyone help? |
|
#2
|
|||
|
|||
|
Quote:
Probably. First, why are you using the older ereg functions instead of the preferred preg ones? Second, forget about regex for the moment. Could you post a couple of example strings and for each string post the desired transformation? Also, describe what exactly is changed for each example. |
|
#3
|
||||
|
||||
|
Quote:
Legacy code from a previous project. Can change it no problem, wasn't aware of a preference for preg_replace thanks Quote:
Sure, first examples from chm source: <A HREF="mk:@MSITStore:ITC_IDR.chm::/B118.htm"> to <A HREF="http://mysite?help=B118"> :: <A HREF="mk:@MSITStore:ITC_IDR.chm::/B156.htm"> to <A HREF="http://mysite?help=B156"> :: second example set from "index" file type <a href='1062.htm'> to <A HREF="http://mysite?help=1062"> :: <a href='LOCAL-B.htm'> to <A HREF="http://mysite?help=LOCAL-B"> Where "http://mysite?help=" is a generic URL to represent what is actually being stored (correctly) in $docroot variable as explained above. Thanks a lot! |
|
#4
|
|||
|
|||
|
Try something like this:
PHP Code:
Last edited by prometheuzz : July 4th, 2009 at 07:43 AM. |
|
#5
|
|||
|
|||
|
Works good
I don't know how to thank you.
|
|
#6
|
|||
|
|||
|
Quote:
Saying that you don't know how to thank me is more than enough gratitude! You're most welcome. |
![]() |
| Viewing: Dev Shed Forums > Programming Languages - More > Regex Programming > "Push" single document root URL rewrite also drop file ext. |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|
|