Re: [users@httpd] mod_rewrite vs Content Management Systems

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



It was thus said that the Great David Blomstrom once stated:
> 
> I don't understand this file system, but it sounds
> like you're referring to folders that list articles
> about various species. 

  Yes. [1]

> In fact, my pages will consist
> of a variety of articles, as well as snippets of
> information  from a MySQL database.
> 
> For example, consider two static pages, each with a
> different $mycode value on the head section:
> 
> $mycode = 'wolf';
> $mycode = 'tiger';
> 
> One would draw data related to the wolf from the
> database, while the other would display information
> about the tiger.
> 
> I haven't yet figured out how CMS's use a single page
> or template to display different articles. But it
> seems like it could be done by simply replacing
> $mycode = 'wolf'; with a variable - $mycode =
> '[VARIABLE]';

  Well, I can explain how my CMS [2] works.  It's a blog, but hey, even
blogging software is a CMS if you look at it the right way.  Anyway, I have
URLs like:

	http://boston.conman.org/2005/08/01.1

  I have Apache rewrite (using mod-rewrite) the URL as:

	RewriteBase /
	RewriteRule ^([0-9][0-9])(.*) nph-boston.cgi/$1$2 [L]

  Or basically, it turns the URL into:

	http://boston.conman.org/nph-boston.cgi/2005/08/01.1

  Apache then runs the request through my CGI program, which looks at the
rest of the reuest, "/2005/08/01.1".  It then figures out what page it
requested, gathers the data, and then spits out a page through a template. 

  The template looks somethink like this (lots and lots of extraneous
HTML removed):

	<html>
 	  <head>
	    <title>The Boston Diaries</title>
	  </head>
	  <body>
	    <div class="header"> ... </div>
	    <div class="content">

		%{entries}%

	    </div>
	  </body>
	</html>

  The script just copies out verbatim the template until it gets to
"%{entries}%", at which point it spits out the requested entry (there can be
more than one by the way---if you go to <http://boston.conman.org/2005/08>
it will spit out an entire month's worth of entries).  The "%{...}%"
construct is how my template engine knows to do some extra processing;
there's %{update.time}% which causes my CMS to generate the time the page
was last modified for instance.  

  Other CMS systems have different ways of marking special processing
instructions.  But generally, they work simularly.

> Then, if a visitor clicked a link to kangaroo, that
> would somehow be translated to $mycode = 'kangaroo';.
> 
> And since my database will include a variety of
> scientific names and common names - like wolf, Canis
> lupus, etc. - it should be relatively easy to insert
> those in my URL's. For example, a URL might look
> something like this:
> 
> www.geozoo.org/stacks;id=Canis_lupus
> 
> I would then like to use mod_rewrite to clean it up so
> that it displays it like this:
> 
> www.geozoo.org/stacks/Canis_lupus
> 
> It would also be cool if it could display additional
> search engine-friendly links from my database, like...
> 
> www.geozoo.org/stacks/wolf
> www.geozoo.org/stacks/Canis_lupus
> www.geozoo.org/stacks/loupe
> 
> But the message I'm getting is that this is hard to do
> with mod_rewrite, so I'd be better off sticking with a
> CMS.

  Not hard per se, but without information about how your CMS takes queries,
it's hard to come up with a definite answer.  

	RewriteRule ^(.*)/(.*)	cmsengine.cgi?area=$1?topic=$2

  is an example, but without knowing what the CMS engine is called, or what
CGI parameters it wants, it's hard to give a good clean answer.

  -spc

[1]	"Filesystem" refers to the structure used to store files and
	directories (or subdirectories, or folders) on a harddrive.

[2]	http://boston.conman.org/about/
	

---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@xxxxxxxxxxxxxxxx
   "   from the digest: users-digest-unsubscribe@xxxxxxxxxxxxxxxx
For additional commands, e-mail: users-help@xxxxxxxxxxxxxxxx



[Index of Archives]     [Open SSH Users]     [Linux ACPI]     [Linux Kernel]     [Linux Laptop]     [Kernel Newbies]     [Security]     [Netfilter]     [Bugtraq]     [Squid]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Samba]     [Video 4 Linux]     [Device Mapper]

  Powered by Linux