Re:Re:Re:Re: Smarty and speed
| From: | Salim Fadhley | Date: | Mon, 10 Dec 2001 00:09:20 +0000 |
| Subject: | Re:Re:Re:Re: Smarty and speed | ||
| References: | 1 | Groups: | php.smarty.general |
| Request: | Send a blank email to php-smarty-general+get-2229@lists.php.net to get a copy of this message | ||
I am glad you like it, although I was wow-ed by Rod-K's approach. His method
demonstrated a deeper knowledge of Apache server, although I think mine is
more practical because you do not need to modify any of your PHP scripts.
Also it works on hosts where you cannot edit httpd.conf.
Just some additional pointers - those $ signs at the end of the first bit
are important - they mean end of the URL. Also, I am sure you guessed that
you can add as many more parameters (I think you can have up to nine???). A
$ followed by a number represents each block of variable text you just
matched. The numbers just keep getting bigger as you need to match more
items.
Once you get the hang of mod_rewrite you will find the same regular
expression syntax used in nearly any UNIX programming language. Its a really
important thing to learn. I learnt PHP regular expressions from this Perl
tutorial...
http://www.english.uga.edu/humcomp/perl/regex2a.html
It seems daunting, but you can go through the whole thing in under an hour.
Actually, I have a big problem with all this - I need a way of doing exactly
the same thing on Microsoft's IIS server. For all it's pretty bells and
whistles I cant think of a way of doing the same thing in Microsoft land.
----- Original Message -----
From: "Brian E. Lozier" <brian@massassi.net>
To: <smarty@lists.ispi.net>
Sent: Sunday, December 09, 2001 11:55 PM
Subject: [smarty] Re:Re:Re:Re: Smarty and speed
> Thanks! This is perfect, I have it working now on my site. This saves me
a LOT of file management...
> *shudder*
>
> Brian
>
> ========================
> The Massassi Temple
> http://www.massassi.net/
> "How should I know if it works? That's what beta testers are for. I only
coded it." - Linus Torvalds
>
> ----- Original Message -----
> From: "Salim Fadhley" <salimfadhley@hotmail.com>
> To: smarty@lists.ispi.net
> Date: 12/9/01 2:41:28 PM
>
> >
> >This is the actual .htaccess file used in the develpment version
> >Sharesite.org. The only diference between this and the live version is
the
> >'RewriteBase' directive. This is because the live one runs in the root of
a
> >virtual host - whereas the dev version runs in /sharesite on my dev box.
I
> >was too lazy to set up virtual hosting!
> >
> >Its all commented but it should be pretty easy to work out anyway. The
first
> >section re-writes the PHP scripts in a number of ways that I used over
the
> >year or so that Sharesite has existed. Because the scripts have changed a
> >bit in this time I need to ensure that every old URL that was ever used
to
> >indicate content still works. As you can see, I am concealing a number of
> >major scripts.
> >
> >The 2nd section deals with spesific pages from the very first incarnation
of
> >sharesite - that was from the days when the site was just a bunch of
static
> >HTML files.
> >
> >Its vital that all of these old URLs stil work. Many of our readers
bookmark
> >pages they enjoy. If I were to loose any of those pages I would loose
quite
> >a bit of our readership. We are lucky as Lunix users to have mod_rewrite.
As
> >far as I know Apache is the only server with a rewriting engine this
cool!
> >
> >Sheb
> >
> >--- .htaccess
> >
> >RewriteEngine on
> >Options +FollowSymlinks
> >RewriteBase /sharesite/
> >RewriteRule crawler.html crawler.php
> >RewriteRule crawler2.html crawler2.php
> >
> ># This rule conceals ?s in Article URLs
> >RewriteRule article/(.*).html$ article.php?article_id=$1
> >RewriteRule article-(.*).html$ article.php?article_id=$1
> >RewriteRule article/(.*)$ $1
> >
> ># This rule conceals ?s in Author URLs
> >RewriteRule author/(.*).html$ author.php?author_id=$1
> >RewriteRule author-(.*).html$ author.php?author_id=$1
> >RewriteRule author/(.*)$ $1
> >
> ># This rule conceals ?s in Feature Indecies
> >RewriteRule feature/(.*).html$ index.php?feature_id=$1&command=feature
> >RewriteRule feature-(.*).html$ index.php?feature_id=$1&command=feature
> >RewriteRule feature/(.*)$ $1
> >
> ># This rule conceals ?s in Company Profiles
> >RewriteRule company-(.*).html$ company.php?company_id=$1&command=feature
> >
> ># This rule conceales the list of Features
> >RewriteRule features.html index.php?command=features
> >
> ># This rule conceales the Main index
> >RewriteRule index.html$ index.php
> >
> ># This rule conceales the Archive
> >RewriteRule archive.html$ index.php?command=archive
> >RewriteRule archives.htm$ index.php?command=archive
> >
> ># This rule conceales the Disclaimer
> >RewriteRule disclaimer.html$ index.php?command=disclaimer
> >RewriteRule disclaimer.htm$ index.php?command=disclaimer
> >
> ># This rule conceales the About Page
> >RewriteRule about.html$ index.php?command=about
> >RewriteRule about.htm$ index.php?command=about
> >
> ># This rule conceales the Letters Page
> >RewriteRule letters.html$ forums/
> >RewriteRule letters.htm$ forums/
> >
> ># These rules re-cycle older links from search engines... nyeah!
> >RewriteRule art001_collapse.htm$ article.php?article_id=26
> >RewriteRule art001_copycat.htm$ article.php?article_id=29
> >RewriteRule art001_fictional.htm$ article.php?article_id=28
> >RewriteRule art001_hours.htm$ article.php?article_id=30
> >RewriteRule art001_nachtmark.htm$ article.php?article_id=33
> >RewriteRule art001_volume.htm$ article.php?article_id=55
> >RewriteRule art001_witches.htm$ article.php?article_id=27
> >RewriteRule art002_flood.htm$ article.php?article_id=32
> >RewriteRule art002_nachtmark.htm$ article.php?article_id=35
> >RewriteRule art002_pedal.htm$ article.php?article_id=54
> >RewriteRule art002_petro.htm$ article.php?article_id=53
> >RewriteRule art002_skive.htm$ article.php?article_id=31
> >RewriteRule art003_exiting.htm$ article.php?article_id=37
> >RewriteRule art003_mobile.htm$ article.php?article_id=34
> >RewriteRule art003_nachtmark.htm$ article.php?article_id=39
> >RewriteRule art003_women.htm$ article.php?article_id=36
> >RewriteRule art004_bloodbath.htm$ article.php?article_id=40
> >RewriteRule art004_nachtmark.htm$ article.php?article_id=39
> >RewriteRule art004_pig.htm$ article.php?article_id=38
> >RewriteRule art005_branding.htm$ article.php?article_id=41
> >RewriteRule art005_prostitution.htm$ article.php?article_id=41
> >RewriteRule art005_tanya.htm$ article.php?article_id=42
> >RewriteRule art006_boarmarket.htm$ article.php?article_id=45
> >RewriteRule art006_mechas.htm$ article.php?article_id=47
> >RewriteRule art006_outsider.htm$ article.php?article_id=44
> >RewriteRule art006_parasitism.htm$ article.php?article_id=46
> >
> ># Sharesite Investigates - this has been replaced by the newer features
> >section
> >RewriteRule art004_investigate_nachtmark.htm$
> >index.php?command=feature&feature_id=1
> >
> ># All these index files will link to The archives section from now on.
> >RewriteRule index001211.htm$ index.php?command=archive
> >RewriteRule index010122.htm$ index.php?command=archive
> >RewriteRule index010219.htm$ index.php?command=archive
> >RewriteRule index120011.htm$ index.php?command=archive
> >RewriteRule index_001211.htm$ index.php?command=archive
> >RewriteRule index_001218.htm$ index.php?command=archive
> >RewriteRule index_010108.htm$ index.php?command=archive
> >RewriteRule index_0ld.htm$ index.php?command=archive
> >RewriteRule index_new.htm$ index.php?command=archive
> >RewriteRule index_template.htm$ index.php?command=archive
> >RewriteRule index_test040301.htm$ index.php?command=archive
> >
> >
> >----- Original Message -----
> >From: "Brian E. Lozier" <brian@massassi.net>
> >To: <smarty@lists.ispi.net>
> >Sent: Sunday, December 09, 2001 5:17 AM
> >Subject: [smarty] Re:Re:Re: Smarty and speed
> >
> >
> >> Will you please post the rewrite junk that you use for it? The code in
> >the previous results in an internal
> >> server errror, and I'm not all that great with regular expressions.
> >>
> >> Honestly, I just need one I can throw into a .htaccess that will
replace
> >things like:
> >>
> >> 2.php
> >> 5.php
> >> 567.php
> >>
> >> With these:
> >> index.php?articleID=2
> >> index.php?articleID=5
> >> index.php?articleID=567
> >>
> >> Thanks in advance!
> >>
> >> Brian
> >>
> >> ========================
> >> The Massassi Temple
> >> http://www.massassi.net/
> >> "How should I know if it works? That's what beta testers are for. I
only
> >coded it." - Linus Torvalds
> >>
> >> ----- Original Message -----
> >> From: "Salim Fadhley" <salimfadhley@hotmail.com>
> >> To: smarty@lists.ispi.net
> >> Date: 12/8/01 5:17:29 PM
> >>
> >> >
> >> >I use mod-rewrite to do exactly that - look on www.sharesite.org -
every
> >PHP
> >> >page is concealed - this makes things a lot better for primative
search
> >> >engines that ignore everything but a vanilla HTML page.
> >> >
> >> >
> >> >
> >> >---
> >> >You are currently subscribed to smarty as: brian@massassi.net
> >> >To unsubscribe send a blank email to
$subst('Email.Unsub')
> >> >Visit Smarty's homepage at
> >> >http://www.phpinsider.com/php/code/Smarty/
> >>
> >>
> >> ---
> >> You are currently subscribed to smarty as: salimfadhley@hotmail.com
> >> To unsubscribe send a blank email to
$subst('Email.Unsub')
> >> Visit Smarty's homepage at
> >> http://www.phpinsider.com/php/code/Smarty/
> >>
> >
> >---
> >You are currently subscribed to smarty as: brian@massassi.net
> >To unsubscribe send a blank email to $subst('Email.Unsub')
> >Visit Smarty's homepage at
> >http://www.phpinsider.com/php/code/Smarty/
>
>
> ---
> You are currently subscribed to smarty as: salimfadhley@hotmail.com
> To unsubscribe send a blank email to $subst('Email.Unsub')
> Visit Smarty's homepage at
> http://www.phpinsider.com/php/code/Smarty/
>