Problem with Not Condition

Why does this URL…


http://local.debbie/account/messages/incoming/by-subject

…not make it past this mod_rewrite…


#Rewrite only if the request is not pointing to a real file.
RewriteCond %{REQUEST_FILENAME} !-f
#NEW
RewriteCond $1 !=account

#Match any kind of Section, Subsection and Article.  PHP will decide if it's valid or not.
RewriteRule (.+)/(.+)/(.+)$ articles/article.php?section=$1&subsection=$2&article=$3 [L]

Things keep going to “articles/article.php” when instead Apache should drop past the mod_rewrite above and look for the correct one…

Sincerely,

Debbie

I ran through this the regex tester I typically use: http://regexlib.com/RETester.aspx?AspxAutoDetectCookieSupport=1

The pattern looks to be a little too generic for you to having a fall through. The expression looks at the whole pattern, and your pattern looks for three groups of any set of characters separated by a forward slash, with these three groups being at the end of the string.

So the pattern matches as

Group 1 - http://local.debbie/account/messages
Group 2 - incoming
Group 3 - by-subject

So group 1 includes additional “matches”, but still matches this pattern at the end. So if you have other patterns that seem to be more specific, those should be first on your list and this one as a fall through.

I feel like I’ll never figure this one out… :frowning:

Here is the larger issue…

Originally, I had my Article/Subsection/Section mod_rewrites are the last ones in my .htaccess file and all was well, because every other pattern in my website was typically one parameter at most, so you’d never have a collision with something like this…


RewriteRule account/request-friend/(.*)$ account/request-friend.php?user=$1 [L]

…or even something sightly more complex like this…


RewriteRule account/view-pm/((.+)/)?(.+)?$ account/view-pm.php?msgview=$2&msg=$3 [L]

But now I have a very dynamic URL to handle sorting of Private Messages like this…


http://local.debbie/account/messages/incoming/by-subject/desc

I had that URL working before I added on the last parameter “desc” and that seems to be what is breaking the camel’s back!!

Consistent with how the rest of my code-base works, a user should be able hack the URL and all of the examples below should be handled gracefully by my “messages.php” script…


http://local.debbie/account/messages/incoming/by-subject/desc
http://local.debbie/account/messages/incoming/by-subject/de
http://local.debbie/account/messages/incoming/by-subject/
http://local.debbie/account/messages/incoming/by-subject
http://local.debbie/account/messages/incoming/by-s
http://local.debbie/account/messages/incoming/
http://local.debbie/account/messages/incoming
http://local.debbie/account/messages/inco
http://local.debbie/account/messages/

(Let me stress again, that I had this functionality working before adding the last SortDirection parameter into the mix!!)

Only when a user gets down to this…


http://local.debbie/account/messages

…would expect a “Page Not Found” error.

The only way I can see to accomplish this goal is by moving my Article + Subsection + Section mod_rewrites BEFORE the Message mod_rewrite, and making it so if the 1st Parameter after www.Debbie.com/ is “account” then the Article + Subsection + Section mod_rewrites are skipped and the Messages mod_rewrite would kick in…

Follow what I am trying to do??

Sincerely,

Debbie

I got it!! :tup:

Debbie