Expression Problem

Discussion in 'PHP' started by dizyn, Jan 19, 2010.

  1. #1
    Hi

    I want / and index.php to go index.php page everything other than that go to shop.php but everything is going to shop.php

    Here is expressing i am using.

    RewriteEngine on
    RewriteRule ^/ index.php
    RewriteRule ^[a-zA-Z]([a-zA-Z.]+) shop.php
    Code (text):
     
    dizyn, Jan 19, 2010 IP
  2. JAY6390

    JAY6390 Peon

    Messages:
    918
    Likes Received:
    31
    Best Answers:
    0
    Trophy Points:
    0
    #2
    RewriteEngine on
    RewriteBase /
    RewriteRule ^/?(index\.php)?$ index.php [L]
    RewriteRule . shop.php [R=301,L]
    Code (markup):
    Try that
     
    JAY6390, Jan 19, 2010 IP
  3. dizyn

    dizyn Active Member

    Messages:
    251
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    53
    #3
    it's working fine for / and index.php

    but not for everything else it says "The page isn't redirecting properly"
     
    dizyn, Jan 19, 2010 IP
  4. dizyn

    dizyn Active Member

    Messages:
    251
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    53
    #4
    RewriteEngine on
    RewriteBase /
    RewriteRule ^/?(index\.php)?$ index.php [L]
    RewriteRule ^[a-zA-Z]([a-zA-Z.]+) shop.php

    this is working fine

    now problem at all now

    I just wanted to know what does [L] Means?
    and
    what does [R=301,L] means?

    Thank you
    dizyn
     
    dizyn, Jan 19, 2010 IP
  5. JAY6390

    JAY6390 Peon

    Messages:
    918
    Likes Received:
    31
    Best Answers:
    0
    Trophy Points:
    0
    #5
    [L] means it's the last instruction, and no other rules are checked
    R=301 means redirect with a 301 HTTP header
    Try this instead
    RewriteEngine on
    RewriteBase /
    RewriteRule ^/?(index\.php)?$ index.php [L]
    RewriteCond %{REQUEST_URI} !^/?shop\.php$
    RewriteRule . shop.php [R=301,L]
    Code (markup):
     
    JAY6390, Jan 19, 2010 IP
  6. szalinski

    szalinski Peon

    Messages:
    341
    Likes Received:
    5
    Best Answers:
    0
    Trophy Points:
    0
    #6
    RewriteRule . shop.php [R=301,L]
    PHP:
    what's the . supposed to mean here - doesn't it mean 'any single character' (in general)? i would have expected

    RewriteRule (.*) shop.php [R=301,L]
    PHP:
    - just my thoughts. :)
     
    szalinski, Jan 19, 2010 IP
  7. JAY6390

    JAY6390 Peon

    Messages:
    918
    Likes Received:
    31
    Best Answers:
    0
    Trophy Points:
    0
    #7
    The first rewrite rule is to see if there is no URI or index.php as the URI. The second checks that the current URI isn't shop.php and then if it isn't it will match against any single character of a uri (and since the blank uri has already been accounted for by the previous rewrite rule it will always match) and rewrite to shop.php
     
    JAY6390, Jan 19, 2010 IP