Having trouble with a rewrite rule

Giganews Newsgroups
Subject: Having trouble with a rewrite rule
Posted by:  Charlie Markwick (charlie.markwi…@gmail.com)
Date: Tue, 13 Sep 2011

I'm using a rewrite rule to parse URLS and break them down into parameters:-

RewriteRule ^([A-Za-z0-9\-]+)/([A-Za-z0-9\-]+)/([A-Za-z0-9\-]+)/([A-Za-z0-9\-]+)/([A-Za-z0-9\-]+)$ /indexa.php?a=$1&b=$2&c=$3&d=$4&e=$5 [L]
RewriteRule ^([A-Za-z0-9\-]+)/([A-Za-z0-9\-]+)/([A-Za-z0-9\-]+)/([A-Za-z0-9\-]+)$ /indexa.php?a=$1&b=$2&c=$3&d=$4 [L]
RewriteRule ^([A-Za-z0-9\-]+)/([A-Za-z0-9\-]+)/([A-Za-z0-9\-]+)$ /indexa.php?a=$1&b=$2&c=$3 [L]
RewriteRule ^([A-Za-z0-9\-]+)/([A-Za-z0-9\-]+)$ /indexa.php?a=$1&b=$2 [L]
RewriteRule ^([A-Za-z0-9\-]+)$ /indexa.php?a=$1 [L]
RewriteRule ^()$ /indexa.php [L]

This has been working fine until I try and install a CMS add in. I put a rule in to exclude the CMS system:-

RewriteRule ^/cms/(.*)$ /cms/$1 [L]

In most cases such as:-

/cms/index.php
/cms/
/cms/apps/users/

The rule behaves fine. However it fails to rewrite URLs to folders without the trailing / eg:-

/cms/content produces a 404 error.

I'm not A1 on Regex. Am I missing something obvious here?

I can't easily change the way that the latter URLs, the ones without the training slash, are coded in the CMS system as it supplied to me to use.

Replies