Forum Moderators: coopster

Message Too Old, No Replies

PATH_INFO or mod_rewrite?

Which to use, when to use, which is faster...

         

mipapage

11:13 pm on Jan 3, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



It's clear that mod_rewrite and rewrite rules are a hot topic [google.com] here on WebmasterWorld.

I'm develeoping the structure for a site, and thought I needed to use a complex RewriteRule to keep the urls clean [google.com].

After reading a lot (great work jdMorgan, andreasfriedrich et al), I threw together the RewriteRule. Happy Days.

Then I came across some rambling by killroy ;-], going on about how variables in the url are 'abused', and that more often than not pages can be delivered using PAGE_PATH.

Fine, I think I get how it works, but can anyone fill me in on why and when I should be using PAGE_PATH, and which method is faster, the above or RewriteRules?

I am building a site where you can drill down thru a topic, ultimately ariving at a page that resides in a table in a db (like a directory, I suppose)... for example:

  • www.mydomain.com - will get you the index page
  • www.mydomain.com/topica/ - will get you the index page of topic a, from table 'maintopics' of the db.
  • www.mydomain.com/topica/subtopic1/ - will get you the page subtopic1, from table 'topica' of the db.

mipapage

3:12 pm on Jan 4, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Am I way out to lunch with this question?

ergophobe

10:42 pm on Jan 4, 2004 (gmt 0)

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



PAGE_PATH?

What is that? I did a Google search and came across some template systems and classes that use it, but I can't find it in the PHP or Apache docs.

Also, why does your rewrite rule need to be complex? It can be very simple? For example, I just do:

RewriteBase /path_beyond_root/
RewriteRule ^(.*)index.php$ - [L]
RewriteRule!(.*)\.(gif¦jpg¦png¦css¦js¦doc)$ /path_beyond_root/index.php [L]

Then I just parse it in index.php. It works for me.

In any case, without actually know what you're talking about, I would say that using Rewrite will be extremely fast on Apache and, as long as mod_rewrite is running, it should work in all cases.

Tom

mipapage

11:17 pm on Jan 4, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Holy creeping potatoes. WHAT THE HECK IS PAGE PATH ANYWAY?

Where did I get that from?

I meant PATH_INFO.

Whew. I wonder how many people came here and said '?huh?' Thanks Tom.



Anyway, someone posted on it [webmasterworld.com] shortly after I started this thread. I've got it working nicely on a site that I'm developing write now.

I just use

RewriteEngine on 
RewriteRule ^(.*)/$ template.php/$1 [L]

and then basically do what is indicated in that thread. It works great, and keeps thing real simple.

ergophobe

11:44 pm on Jan 4, 2004 (gmt 0)

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




Am I way out to lunch


Holy creeping potatoes.

Like to eat, do you?

mipapage

12:09 am on Jan 5, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Funny this. I just finished eating and here I am, reading that [-:

ergophobe

4:23 pm on Jan 5, 2004 (gmt 0)

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



Hey! No frown! Eating is a good thing. You can take my earlier comment as praise (bemused praise, I'll admit), not criticism.

Tom

mipapage

4:40 pm on Jan 5, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Oh! That wasn't a frown, I just tried turning a happy face upside... I mean, over on it's side, like this:

[-:

instead of this:

:-]

Either way both happy!

(Sorry jatar_k!)