Please whitelist cPanel in your adblocker so that you’re able to see our version release promotions, thanks!

The Community Forums

Interact with an entire community of cPanel & WHM users!

Mod Rewrite expert, I need help

Discussion in 'General Discussion' started by sodapopinski, Oct 19, 2015.

  1. sodapopinski

    sodapopinski Well-Known Member

    Joined:
    Aug 13, 2001
    Messages:
    90
    Likes Received:
    2
    Trophy Points:
    308
    I want to set a website where user can get theirname.mydomain.com.

    Lets say my domain is domain.com and I already activated wild card setting into the httpd.conf config.

    What I want:

    1. When abc.domain.com accessed, the server will process domain.com/index.php?user=abc

    2. When abc.domain.com/product_1_rose.html accessed, the server will process domain.com/index.php?user=abc&prodid=1&prodname=rose

    (note abc, 1 and rose are the any number and words depending on user type in browser)

    I tried the following config:
    ------------------------------------------------------------------------------------------
    RewriteCond %{HTTP_HOST} ^((?!www\.)[^.]+)\.domain\.com$
    RewriteCond %{REQUEST_URI} !^/index\.php$ [NC]
    RewriteRule ^(.*)$ /index.php?user=%1
    RewriteRule ^productid_([0-9]+)_([0-9a-z-]).html$ /index.php?prodid=$1&prodname=$2&user=%1
    ------------------------------------------------------------------------------------------

    But, it doesnt work. When opening abc.domain.com/product_1_rose.html, it will open the abc.domain.com default page.
    If I removed rule: RewriteRule ^(.*)$ /index.php?user=%1, the rule for abc.domain.com/product_1_rose.html works well, BUT abc.domain.com failed to load into the browser.
    So, How can make both of these rule work?

    Anybody have the idea? I'm willing to send some $ by paypal if the code works ;p

    Thank you very much.
     
  2. cPanelMichael

    cPanelMichael Forums Analyst
    Staff Member

    Joined:
    Apr 11, 2011
    Messages:
    43,711
    Likes Received:
    1,791
    Trophy Points:
    363
    cPanel Access Level:
    Root Administrator
    Hello :)

    You will likely receive more user-feedback on custom Mod_Rewrite rules on a website where more discussions of Mod_Rewrite occur, such as StackOverflow.

    Thank you.
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
Loading...

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice