Regular expression help

Discussion in 'PHP' started by dizyn, May 4, 2011.

  1. #1
    I am facing problem in regular expressing, please help me.

    My website has two files, index.php, myshop.php when user access mywebsite.com it should take them to index.php and when they try mywebsite.com/anyshop it should take them to that shop.

    Here is what i did for this but it did not work.

    RewriteEngine on
    RewriteBase /
    RewriteRule ^/?(index\.php)?$ index.php [L]
    RewriteRule ^/([a-zA-Z0-9]+)/([0-9-a-z-A-Z]+)/([a-z]+)/([0-9]+)$ shop.php?shop=$1&catid=$2&order=$3&page=$4
    RewriteRule ^/([a-zA-Z0-9]+)/([0-9-a-z-A-Z]+)/([a-z]+)$ shop.php?shop=$1&catid=$2&order=$3
    RewriteRule ^/([a-zA-Z0-9]+)/([a-z]+)/([0-9]+)$ shop.php?shop=$1&order=$2&page=$3
    RewriteRule ^/([a-zA-Z0-9]+)/([a-z]+)$ shop.php?shop=$1&order=$2
    RewriteRule ^/([a-zA-Z0-9.]+)/([0-9]+)$ shop.php?shop=$1&page=$2
    RewriteRule ^/([a-zA-Z0-9]+)/([0-9-a-z-A-Z]+)/([0-9]+)$ shop.php?shop=$1&catid=$2&page=$3
    RewriteRule ^/([a-zA-Z0-9]+)/([0-9-a-z-A-Z]+)$ shop.php?shop=$1&catid=$2
    RewriteRule ^/([a-zA-Z0-9.]+) shop.php?shop=$1
    RewriteRule ^item/([0-9]+)$ item_detail.php?id=$1
    Code (markup):
    If i make a folder/directory named shopping and try this, it works fine but don't want to keep shopping there, i want it to work without shopping. like myshop.com/anything.


    RewriteRule ^shopping/([a-zA-Z0-9]+)/([0-9-a-z-A-Z]+)/([a-z]+)/([0-9]+)$ shop.php?shop=$1&catid=$2&order=$3&page=$4
    RewriteRule ^shopping/([a-zA-Z0-9]+)/([0-9-a-z-A-Z]+)/([a-z]+)$ shop.php?shop=$1&catid=$2&order=$3
    RewriteRule ^shopping/([a-zA-Z0-9]+)/([a-z]+)/([0-9]+)$ shop.php?shop=$1&order=$2&page=$3
    RewriteRule ^shopping/([a-zA-Z0-9]+)/([a-z]+)$ shop.php?shop=$1&order=$2
    RewriteRule ^shopping/([a-zA-Z0-9.]+)/([0-9]+)$ shop.php?shop=$1&page=$2
    RewriteRule ^shopping/([a-zA-Z0-9]+)/([0-9-a-z-A-Z]+)/([0-9]+)$ shop.php?shop=$1&catid=$2&page=$3
    RewriteRule ^shopping/([a-zA-Z0-9]+)/([0-9-a-z-A-Z]+)$ shop.php?shop=$1&catid=$2
    RewriteRule ^shopping/([a-zA-Z0-9.]+) shop.php?shop=$1
    RewriteRule ^item/([0-9]+)$ item_detail.php?id=$1
    Code (markup):

     
    dizyn, May 4, 2011 IP
  2. phppro9x

    phppro9x Peon

    Messages:
    15
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #2
    You can used
    RewriteEngine on
    RewriteBase /shopping
    RewriteRule ^/?(index\.php)?$ index.php [L]
    RewriteRule ^/([a-zA-Z0-9]+)/([0-9-a-z-A-Z]+)/([a-z]+)/([0-9]+)$ shop.php?shop=$1&catid=$2&order=$3&page=$4
    RewriteRule ^/([a-zA-Z0-9]+)/([0-9-a-z-A-Z]+)/([a-z]+)$ shop.php?shop=$1&catid=$2&order=$3
    RewriteRule ^/([a-zA-Z0-9]+)/([a-z]+)/([0-9]+)$ shop.php?shop=$1&order=$2&page=$3
    RewriteRule ^/([a-zA-Z0-9]+)/([a-z]+)$ shop.php?shop=$1&order=$2
    RewriteRule ^/([a-zA-Z0-9.]+)/([0-9]+)$ shop.php?shop=$1&page=$2
    RewriteRule ^/([a-zA-Z0-9]+)/([0-9-a-z-A-Z]+)/([0-9]+)$ shop.php?shop=$1&catid=$2&page=$3
    RewriteRule ^/([a-zA-Z0-9]+)/([0-9-a-z-A-Z]+)$ shop.php?shop=$1&catid=$2
    RewriteRule ^/([a-zA-Z0-9.]+) shop.php?shop=$1
    RewriteRule ^item/([0-9]+)$ item_detail.php?id=$1
    Hope it helps
     
    phppro9x, May 4, 2011 IP