The Community Forums

Interact with an entire community of cPanel & WHM users!
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

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:
    79
    Likes Received:
    0
    Trophy Points:
    6
    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:
    30,830
    Likes Received:
    672
    Trophy Points:
    113
    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.
     
Loading...

Share This Page