Forum Moderators: phranque
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} ^.*\.(php)$
RewriteRule ^([^/]+)\/([^/]+)?[\/]?([^/]+)?[\/]?([^/]+)?[\/]?([^/]+)?[\/]?$ $1?q1=$2&q2=$3&q3=$4&q4=$5 [QSA]
[\/]? simplifies to /? ^.*\. in your pattern should be replaced by ^([^/]+/)+\. or similar. Never use .* at the beginning or in the middle of a pattern. ^([^/]+)/(([^/]+/)*)([^/.]+)$ (use $1, $2, $4) or ^([^/]+)/(([^/]+/)*[^/.]+)$ (use $1, $2) to capture multiple folder groups all at once in $2 (and $4 in first code snippet) and then explode and count them within the PHP script. Map $1 to the internal php file. [L] flag. RewriteCond %{REQUEST_FILENAME} ^.*\.(php)$ RewriteCond $1\.php -f $1?q1=... with /$1.php?q1=... RewriteCond %{REQUEST_URI} !-d
RewriteCond $1\.php -f
RewriteRule ^([^/]+)/(([^/]+/)*[^/.]+)$ /$1.php?multi=$2 [QSA,L]