URL rewrite splitting

Discussion in 'PHP' started by AmidalaX, Jun 26, 2010.

  1. #1
    Hi there,

    I want to make subdomain url rewrite for categories and user profiles.. For example:
    category.mysite.com -> categories.php?kat=category
    username.mysite.com -> profiles.php?prof=username

    How can I do this? I was thinking about rewriting it to check.php?check=$1, which will check if category exists and include categories.php. If not include profiles.php. Is this good solution or is another(better) way to do this (Apache+PHP)? Thank you for answers.
     
    AmidalaX, Jun 26, 2010 IP
  2. Narrator

    Narrator Active Member

    Messages:
    392
    Likes Received:
    9
    Best Answers:
    0
    Trophy Points:
    80
    #2
    For that to work you have to first enable wildcard subdomains in either cpanel or apache settings, so that *.mysite.com get resolved to the same ip address and directory.

    There is a few threads on this here's one, http://forums.digitalpoint.com/showthread.php?t=33868
     
    Narrator, Jun 29, 2010 IP
  3. webria

    webria Peon

    Messages:
    43
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Please check if wild char *.domain.com works without a dedicated IP.
     
    webria, Jul 6, 2010 IP
  4. YoGem

    YoGem Active Member

    Messages:
    676
    Likes Received:
    8
    Best Answers:
    2
    Trophy Points:
    90
    #4
    Don't be discouraged! Wildcards works also without dedicated IP, you can do it by playing with the .htaccess file that usually is invisible (unix: .dottedfiles - yes the dot is before the filename - are invisibles) so you need to turn on on your FTP client the "Show invisible files". Then you'll need to edit the .htaccess! And as Narrator said, visit this link:http://forums.digitalpoint.com/showthread.php?t=33868 - This is the solution :)
     
    YoGem, Jul 8, 2010 IP