.htaccess subdomain problem

Discussion in 'Apache' started by Throk, Nov 2, 2012.

  1. #1
    This is piece of mine .htaccess file:

    RewriteCond %{HTTP_HOST} !^www\.example.com
    RewriteCond %{HTTP_HOST} ([^.]+)\.example.com
    RewriteRule ^(.*)$ index.php?pg=%1&page=$1
    
    Code (markup):
    Above will redirects www.sub.example.com into index.php?pg=sub&page=

    Problem is that I want to make secound variable subsidiary by this what I give behind domain name.
    Ex.

    sub.example.com/info ---> index.php?pg=sub&page=info
    Code (markup):
    This what I gave should do the trick. I tested it here: http://htaccess.madewithlove.be/ and it works. But when I add it on server the secound variable is always "index.php". Ex.

    sub.example.com/info ---> index.php?pg=sub&page=index.php
    Code (markup):
    What is the problem? How can I solve it? Please help!
     
    Throk, Nov 2, 2012 IP
  2. mangoo

    mangoo Peon

    Messages:
    27
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Do you have any other redirects earlier?

    Can you try, from command line:

    wget -O /dev/null sub.example.com/info

    This will show you all redirects on the way.

    I bet $1 that sub.example.com/info redirects you to sub.example.com/index.php first.
     
    mangoo, Nov 2, 2012 IP
  3. Throk

    Throk Peon

    Messages:
    4
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Yes I have some code before it, but nothing special:

    AddDefaultCharset utf-8
    Options FollowSymLinks
    RewriteEngine On
    RewriteBase /
    
    Code (markup):
    I used this command that You gave me. Result and whole .htaccess file is on Your PM. I hope that you can help me
     
    Throk, Nov 2, 2012 IP
  4. Throk

    Throk Peon

    Messages:
    4
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #4
    Anyone? Please it's important
     
    Throk, Nov 3, 2012 IP
  5. wetbupa

    wetbupa Peon

    Messages:
    119
    Likes Received:
    2
    Best Answers:
    1
    Trophy Points:
    0
    #5
    wetbupa, Nov 5, 2012 IP
  6. Throk

    Throk Peon

    Messages:
    4
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #6
    Nvm problem is solved. I used this:

    RewriteCond %{HTTP_HOST} !^www\.example.com
    RewriteCond %{HTTP_HOST} ([^.]+)\.example.com
    RewriteCond %{DOCUMENT_ROOT}/%2 -d
    RewriteRule ^(.*)$ index.php?pg=%1&page=$1 [L,QSA]
     
    Throk, Nov 5, 2012 IP
  7. wetbupa

    wetbupa Peon

    Messages:
    119
    Likes Received:
    2
    Best Answers:
    1
    Trophy Points:
    0
    #7
    I am glad for you :)
     
    wetbupa, Nov 5, 2012 IP