Redirecting subdomain and directory to .com/index.php?sub=subdomain&dir=directory

Discussion in 'Apache' started by weaverweb, May 15, 2011.

  1. #1
    Hi,

    I have the .htaccess currently set to redirect the subdomain into the url like below.

    RewriteCond %{HTTP_HOST} !^www\.paymonthlyphones\.mobi$ [NC]
    RewriteCond %{HTTP_HOST} ^(www\.)?([^\.]+)\.paymonthlyphones\.mobi$ [NC]
    RewriteRule ^$ /phone.php?phone=%2 [QSA,nc]
    Code (markup):
    I need to do something like the below but I cannot figure it out.

    RewriteCond %{HTTP_HOST} ^(www\.)?([^\.]+)\.paymonthlyphones\.mobi/([^\.]+)$ [NC]
    RewriteRule ^(www\.)paymonthlyphones.mobi/phone.php?phone=$1&moreinfo=$2 [QSA,nc]
    Code (markup):
    Any help would be greatly appreciated.
     
    Last edited: May 15, 2011
    weaverweb, May 15, 2011 IP
  2. weaverweb

    weaverweb Peon

    Messages:
    4
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #2
    I've tried the following and get a 404 /more was not found.

    RewriteCond %{HTTP_HOST} ^(www\.)?(.*)\.paymonthlyphones\.mobi/more$ [NC]
    RewriteRule ^$ /phone.php?phone=%2&more=yes [QSA,nc]
    Code (markup):
    Am I missing something simple?
     
    weaverweb, May 15, 2011 IP
  3. weaverweb

    weaverweb Peon

    Messages:
    4
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    If this works.

    RewriteEngine on
    
    RewriteCond %{HTTP_HOST} !^www\.paymonthlyphones\.mobi$ [NC]
    RewriteCond %{HTTP_HOST} ^(www\.)?([^\.]+)\.paymonthlyphones\.mobi$ [NC]
    RewriteRule ^$ /phone.php?phone=%2 [QSA,nc]
    Code (markup):
    Then why doesn't this?

    RewriteEngine on
    
    RewriteCond %{HTTP_HOST} !^www\.paymonthlyphones\.mobi/more/$ [NC]
    RewriteCond %{HTTP_HOST} ^(www\.)?([^\.]+)\.paymonthlyphones\.mobi/more/$ [NC]
    RewriteRule ^$ /phone.php?phone=%2&more=true [QSA,nc]
    Code (markup):
    I think I'm just missing something simple here, i've tried 100 different combinations, and still no where closer...
     
    weaverweb, May 15, 2011 IP