RE: [PHP] Re: rewrite rule help anyone?
| From: | Siddharth Hegde | Date: | Wed, 26 Feb 2003 07:48:59 +0000 |
| Subject: | RE: [PHP] Re: rewrite rule help anyone? | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-137196@lists.php.net to get a copy of this message | ||
Sorry did not get you there specifically this part
> > ---This:
> > index.php?file=test&cmd=display&what=all
> > ---Becomes:
> > index-get-file-is-test+cmd-is-display+what-is-all.html
Anyway, I have written a rewrite rule to rewrite
www.<subdomain>.some-domain.com to
www.some-domain.com/index.php?somevar=<sub-domain>
Is this what you are looking for?
- Sid
> -----Original Message-----
> From: Shawn McKenzie [mailto:nospam@mckenzies.net]
> Sent: Monday, February 24, 2003 4:07 AM
> To: php-general@lists.php.net
> Subject: [PHP] Re: rewrite rule help anyone?
>
> No takers???
>
> Did I say, Please!
>
> Thanks!
> Shawn
>
> "Shawn McKenzie" <nospam@mckenzies.net> wrote in message
> news:20030222212546.92564.qmail@pb1.pair.com...
> > Slightly off topic, but I have some PHP also ;-)
> >
> > I am trying to make search engine friendly URLs for a site, but want
> this
> to
> > be fairly dynamic and work with any new script and vars.
> >
> > If anyone would be willing, I need help on a mod_rewrite rule or
rules?
> I'm
> > thinking it should be fairly simple, but I know nothing about reg
> > expressions. Maybe not the greatest, but here's the code that
generates
> the
> > HTML with altered URLs. This works great, but then I need Apache to
> rewrite
> > these.
> >
> > ---This:
> > index.php?file=test&cmd=display&what=all
> > ---Becomes:
> > index-get-file-is-test+cmd-is-display+what-is-all.html
> >
> > --Here's the code:
> >
> > ob_start();
> > echo $htmlpage;
> > $newdisplay = ob_get_contents();
> > ob_clean_flush();
> > echo rewrite($newdisplay);
> >
> > function rewrite($newdisplay)
> > {
> > $search = array(
> > ".php?", ".php", "=", "&",
> > "&");
> >
> > $replace = array(
> > "-get-", "", "-is-", "+", "+");
> >
> > $hrefs = find_hrefs($newdisplay);
> > $tmphrefs = str_replace($search, $replace, $hrefs);
> > foreach($tmphrefs as $key => $array) {
> > $newhrefs[$key] = $array.".html";
> > }
> > $newdisplay = str_replace($hrefs, $newhrefs, $newdisplay);
> >
> > return $newdisplay;
> > }
> >
> > //finds href=" in the string containing the html
> > function find_hrefs($tmpcontent)
> > {
> > while($start = strpos($tmpcontent, 'href="', $end)) {
> > $start = $start +6;
> > $end = strpos($tmpcontent, '"', $start);
> > $href[] = substr($tmpcontent, $start, $end - $start);
> > }
> > return $href;
> > }
> >
> > TIA,
> > Shawn
> >
> >
>
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php