SitePoint Sponsor

User Tag List

Results 1 to 2 of 2

Hybrid View

  1. #1
    SitePoint Member
    Join Date
    Nov 2011
    0 Post(s)
    0 Thread(s)

    Help me, htacces define the rules of the dynamic domain name

    I really need your help because I can not solve this problem.
    I want to use htaccess to achieve the following functions:
    Access or, the url will be redirected to: /website.php?subdomain=xxxx, and the "xxxx" can not contain certain strings such as www, admin, email and so on.
    Access, the url will be redirected to: /category.php?subdomain=xxxx&cid=89
    Access, the url will be redirected to: /document.php?subdomain=xxxx&did=1234

    I tried the following rules, but only achieved the first step, the second and third steps have failed, please help me.

    RewriteCond %{HTTP_HOST} (?!www|shop|bbs|home|pay|account|admin|cms|image|mobile|m|wap)^[a-z0-9\-]+\.domain\.com$
    RewriteRule ^/?$ /%{HTTP_HOST}
    RewriteRule ^/([a-z0-9\-]+)\.domain\.com/?$ /website.php?subdomain=$1

    thank you very much

  2. #2
    Certified Ethical Hacker silver trophybronze trophy dklynn's Avatar
    Join Date
    Feb 2002
    19 Post(s)
    3 Thread(s)

    Okay, your explanation is fine (for a "specification") so, using pseudo code:

    1. Handle the EMPTY {REQUEST_URI} string by capturing the subdomain (exclude list) and redirecting to website.php?subdomain=%1

    (I don't see that in your code so that's one point where you need to fix your code.)

    2. THEN handle the categoryxx request by capturing the digits following category and ADDING (think QSA to retain the subdomain value) cid=$1

    3. THEN repeat step 2 for documentxx with did=$1

    If you can't translate the above and get it to work, show your translation and I'll correct it for you (because you can only learn by trying - with guidance - and not by copying someone else's scripts).


    David K. Lynn - Data Koncepts is a long-time WebHostingBuzz (US/UK)
    Client and (unpaid) WHB Ambassador
    mod_rewrite Tutorial Article (setup, config, test & write
    mod_rewrite regex w/sample code) and Code Generator

Tags for this Thread


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts