SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Wizard DoubleDee's Avatar
    Join Date
    Aug 2010
    Location
    Arizona
    Posts
    3,764
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)

    Problem with Not Condition

    Why does this URL...
    Code:
    http://local.debbie/account/messages/incoming/by-subject
    ...not make it past this mod_rewrite...
    Code:
    #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

  2. #2
    Just Blow It bronze trophy
    DaveMaxwell's Avatar
    Join Date
    Nov 1999
    Location
    Mechanicsburg, PA
    Posts
    7,263
    Mentioned
    115 Post(s)
    Tagged
    1 Thread(s)
    I ran through this the regex tester I typically use: http://regexlib.com/RETester.aspx?As...ookieSupport=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.
    Dave Maxwell - Manage Your Site Team Leader
    My favorite YouTube Video! | Star Wars, Dr Suess Style
    Learn how to be ready for The Forums' Move to Discourse

  3. #3
    SitePoint Wizard DoubleDee's Avatar
    Join Date
    Aug 2010
    Location
    Arizona
    Posts
    3,764
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by DaveMaxwell View Post
    I ran through this the regex tester I typically use: http://regexlib.com/RETester.aspx?As...ookieSupport=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...

    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...
    Code:
    RewriteRule account/request-friend/(.*)$ account/request-friend.php?user=$1 [L]
    ...or even something sightly more complex like this...
    Code:
    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...
    Code:
    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...
    Code:
    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...
    Code:
    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

  4. #4
    SitePoint Wizard DoubleDee's Avatar
    Join Date
    Aug 2010
    Location
    Arizona
    Posts
    3,764
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    I got it!!


    Debbie


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •