ForceType versus mod_rewrite

Not for 'how-to' coding questions but PHP theory instead, this forum is here for those of us who wish to learn about design aspects of programming with PHP.

Moderator: General Moderators

Post Reply
User avatar
nielsene
DevNet Resident
Posts: 1834
Joined: Fri Aug 16, 2002 8:57 am
Location: Watertown, MA

ForceType versus mod_rewrite

Post by nielsene »

This is slightly related to my Front Controller thread:

I'm trying to figure out the advantages/disadvantages of using ForceType versus mod_rewrite to generate clean URLs. (I'm leaving out the custom 404 method as I feel its polluting of the error log is a strong enough disincentive.)

I've been using ForceType so far, but one little details is making me want to explore mod_rewrite. Most tutorials I've seen only list one or the other and don't go into details as to their trade-offs.

Assuming you have sufficient control of httpd.conf and/or .htaccess, what are the pros/cons?

As I see it:
ForceType:
Pros: Simpler, less processing?
Cons: Extentionless scripts confuse phpDocumentor, configuration can get more psread out

and the flip for mod_rewrite.
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

I'd tend to swing at mod_rewrite, because:
- more flexible, you could have it run a script to "help" determine the thing to send
- it's regex, I love regex, as you may know.

however:
- can be somewhat painful to deal with depending on what you want to do (unless you send everything through a script, then it can get a lot easier) :)

Dunno.

I'd say they are kinda even.
User avatar
nielsene
DevNet Resident
Posts: 1834
Joined: Fri Aug 16, 2002 8:57 am
Location: Watertown, MA

Post by nielsene »

feyd wrote:I'd tend to swing at mod_rewrite, because:
- more flexible, you could have it run a script to "help" determine the thing to send
What do you mean by this? Are you saying you can use mod_rewrite to direct all traffic through a single script? If so that's also true for the ForceType approach. If not, can you explain a little more of what you mean?
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

not only can you send all things through a script, you can send matched things through a script. So certain patterns can fluctuate which script they actually call if needed. Granted, you can kind of do that with ForceType as well.
User avatar
Todd_Z
Forum Regular
Posts: 708
Joined: Thu Nov 25, 2004 9:53 pm
Location: U Michigan

Post by Todd_Z »

Can i see the .htaccess code for sending urls through a script with the mod_rewrite method? Sounds interesting.
nthitz
Forum Newbie
Posts: 5
Joined: Fri Aug 12, 2005 5:03 pm

Post by nthitz »

Todd_Z wrote:Can i see the .htaccess code for sending urls through a script with the mod_rewrite method? Sounds interesting.
Heres a very simple one, and may not work depending on what your doing

Code: Select all

RewriteEngine on
RewriteRule !\.(gif|jpg|png|css|js)$  	/home/nthitz/public_html/index.php
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

it's actually:
RewriteMap

look for prg as a MapType..
nthitz
Forum Newbie
Posts: 5
Joined: Fri Aug 12, 2005 5:03 pm

Post by nthitz »

Well it works for me, so I dunno.
User avatar
Todd_Z
Forum Regular
Posts: 708
Joined: Thu Nov 25, 2004 9:53 pm
Location: U Michigan

Post by Todd_Z »

Yea, i use mod_rewrite all the time - i was curious about using the RewriteMap with php scripts
Post Reply