SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Member
    Join Date
    Jul 2011
    Posts
    1
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Please help in htaccess !

    Hello ,

    I have programmed an small script for my members

    script job is

    1- They can create them folder on my site
    2- They can create unlimted html pages in them folder on my site !

    i have configured wildcard on server and it's ok

    every thing is okay

    i need only htaccess file

    i want htaccess do that

    Code:
    1 - rewrite [VALUE1].mysite.com ----- mysite.com/folder.php?foldername=[VALUE1]
    Code:
    2 - rewrite [VALUE1].mysite.com/[VALUE2] ---- mysite.com/folder.php?foldername=[VALUE1]&[VALUE2]
    above the [VALUE2] is the query for every folder
    EXAMPLE
    Code:
    mysite.com/folder.php?foldername=test1&page=about_me&paged=2
    Here [VALUE1] is [test1]
    [VALUE2] is [page=about_me&paged=2]

    Please Help

    i finnaly finished my script after 4 months work !

    and really need your help !

    --------
    some one asked this question before
    here the post

    http://www.sitepoint.com/forums/apac...ns-580081.html

    and they answered him right

    but he required only one value [ profile.php?username=[NAME]
    i required two values [folder.php?foldername=[VALUE 1]&[VALUE 2]

    Regards

  2. #2
    Certified Ethical Hacker silver trophybronze trophy dklynn's Avatar
    Join Date
    Feb 2002
    Location
    Auckland
    Posts
    14,604
    Mentioned
    19 Post(s)
    Tagged
    2 Thread(s)
    Alla,

    You are trying to capture the username from the subdomain and a filename, too. No problem.

    IMHO, you should NOT attempt to redirect to the main domain but the subdomain should be pointed at the main domain (SHARED DocumentRoot) and allow mod_rewrite to fetch the subdomain's folder (because it makes your redirections easier when the URL does not change).
    Code:
    1 - rewrite [VALUE1].mysite.com ----- mysite.com/folder.php?foldername=[VALUE1]
    mod_rewrite:
    Code:
    RewriteEngine on
    RewriteCond %{HTTP_HOST} !^www\.mysite\.com$
    RewriteCond %{HTTP_HOST} ^([a-z]+)\.mysite\.com [NC]
    # NOTA BENE: The subdomain and folder must be lowercase!
    RewriteRule ^$ folder.php?foldername=%1 [L]
    Code:
    2 - rewrite [VALUE1].mysite.com/[VALUE2] ---- mysite.com/folder.php?foldername=[VALUE1]&[VALUE2]
    continuing the above code:
    Code:
    RewriteCond %{HTTP_HOST} !^www\.mysite\.com$
    RewriteCond %{HTTP_HOST} ^([a-z]+)\.mysite\.com [NC]
    # again, the subdomain and folder must be lowercase!
    RewriteRule ^([a-z./]+)$ folder.php?foldername=%2&link=$1 [L]
    # I added a key name of "link" for $1 to enable it to be accessed properly
    # the path/filename must be lowercase letters only (with / and . as appropriate)
    It's NOT rocket science but a simple subset of regular expressions applied to simple Apache variables. Have a look at the tutorial linked in my signature for more information.

    Regards,

    DK
    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


Bookmarks

Posting Permissions

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