regular express problem

Discussion in 'PHP' started by dizyn, Jul 30, 2008.

  1. #1
    Hi

    I am having problem in fixing the regular expression.
    I want to forward all calls to shop.php but at the same time if[there is call i.e www.example.com then it should took it to index.php not the shop.php

    here is my current expression, it always throw pages to shop.php even if want to go index.php it will take me to shop.pop

    RewriteEngine on
    RewriteRule ^/ index.php
    RewriteRule ^([a-zA-Z0-9.]+) shop.php
    Code (markup):

     
    dizyn, Jul 30, 2008 IP
  2. yleiko

    yleiko Peon

    Messages:
    74
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    0
    #2
    you should escape the .

    RewriteEngine on
    RewriteRule ^/ index.php
    RewriteRule ^([a-zA-Z0-9\.]+) shop.php
     
    yleiko, Jul 30, 2008 IP
  3. dizyn

    dizyn Active Member

    Messages:
    251
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    53
    #3
    thank you, but how can i stop it from going to shop.php if i am calling index.php it should not go to shop.php

    any help

    thanks
     
    dizyn, Jul 30, 2008 IP
  4. yleiko

    yleiko Peon

    Messages:
    74
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    0
    #4
    try this one
    RewriteRule ^index\.html index.php
     
    yleiko, Jul 30, 2008 IP
  5. dizyn

    dizyn Active Member

    Messages:
    251
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    53
    #5
    nops

    i tried RewriteRule ^index\.html index.php and RewriteRule ^index.html index.php
     
    dizyn, Jul 30, 2008 IP
  6. mallorcahp

    mallorcahp Peon

    Messages:
    141
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #6
    You have to tell it not to process any more rules ... [L]

    Try this

    
    RewriteEngine on
    RewriteRule ^/$ index.php [L]
    RewriteRule ^index.php$ index.php [L]
    RewriteRule ^([a-zA-Z0-9.]+)$ shop.php
    
    Code (markup):
    don't think you need to escape the . if you are using it as a wildcard search, only if you are using to find "." exact match ... eg \.html
     
    mallorcahp, Jul 30, 2008 IP