View Single Post
10-16-2006, 06:04 PM
#4
Salathe is offline Salathe
Salathe's Avatar
Status: Community Archaeologist
Join date: Jul 2004
Location: Scotland
Expertise: Software Development
Software: vim, PHP
 
Posts: 3,820
iTrader: 25 / 100%
 

Salathe will become famous soon enough

Send a message via MSN to Salathe

  Old

Well, it seems you've got a working solution so there's no need for a 'correction'. However, I can explain why an infinite loop was happening in the first snippet.

The RewriteRule is saying, "if the requested file doesn't end in .gif, ... .css then go to /test/index.php". However, when the request is made to index.php it doesn't end in .gif, ... .css and so redirects another time to /test/index.php. And because index.php doesn't end in.... You get the idea.

A method that I use is slighly different and may or may not be more beneficial for you would be something along the lines of:
PHP Code:
# Rewriting requests for pretty URLs
RewriteEngine On

# Allowed request are from 1 to 3 levels deep:
# domain.com/section
# domain.com/section/page
# domain.com/section/page/cruft
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond 
%{REQUEST_FILENAME} !-d
RewriteCond 
%{REQUEST_URI} ^/rewrite(/[a-zA-Z0-9_\-]+){1,3}/?$
RewriteRule ^([^/]+)/?$ index.php?sec=$[QSA,L]
RewriteRule ^([^/]+)/([^/]+)/?$ index.php?sec=$1&page=$[QSA,L]
RewriteRule ^([^/]+)/([^/]+)/([^/]+)/?$ index.php?sec=$1&page=$2&etc=$[QSA,L
A little more confusing, perhaps, but it should be a good starting (or ending!) point for you.