Help with .htaccess

Discussion in 'Programming' started by holyguy2005, Nov 15, 2007.

  1. #1
    Can anyone help me with the following .htacess problem.

    The contents of my .htaccess are as follows :

    
    RewriteEngine on
    
    RewriteCond  $1  !^blog
    
    RewriteCond  $1  ^blog
    
    RewriteRule ^([^/\.]+)?/?([^/\.]+)?/?([^/\.]+)?/?([^/\.]+)?/?$ blog.php?sub_section=$2&id=$3&title=$4&ht_url=true [L]
    
    Code (markup):
    With the above rule, whenever someone enters the address http://www.mydomain.com/blog, it takes them to the specific blog.php page.

    But also, whenever someone enters something like http://www.mydomain.com/blogger or http://www.mydomain.com/blogggggggg , it takes them to the blog.php page and not the subdomain "blogger" or "blogggggg"

    So, when the first four letters match "blog", it takes them to the blog.php and not the subdirectory I want.


    What do I have to edit in the rule there to have my subdomains working?

    Thanks in advance.
     
    holyguy2005, Nov 15, 2007 IP
  2. holyguy2005

    holyguy2005 Member

    Messages:
    93
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    43
    #2
    come on.. any one?
     
    holyguy2005, Nov 15, 2007 IP
  3. krt

    krt Well-Known Member

    Messages:
    829
    Likes Received:
    38
    Best Answers:
    0
    Trophy Points:
    120
    #3
    Bit confused but is this what you want?

    RewriteEngine On
    RewriteBase /
    RewriteRule ^blog$ blog.php [L]
    RewriteRule ^([^/\.]+)?/?([^/\.]+)?/?([^/\.]+)?/?([^/\.]+)?/?$ blog.php?sub_section=$2&id=$3&title=$4&ht_url=true [L]
     
    krt, Nov 15, 2007 IP
  4. holyguy2005

    holyguy2005 Member

    Messages:
    93
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    43
    #4
    After reading some htacess mod_rewrite tutorials, I found the soluion..
    "RewriteCond $1 !^blog" -> There was a missing "$" at the end.

    Anyways krt, thanks for your response.
     
    holyguy2005, Nov 15, 2007 IP
  5. krt

    krt Well-Known Member

    Messages:
    829
    Likes Received:
    38
    Best Answers:
    0
    Trophy Points:
    120
    #5
    What tutorial are you looking at? I consider myself fairly well versed with mod_rewrite but have never come across the $1 marker in a RewriteCond statement. Might try it myself but I think it's working only because the parser is guessing what you want to do.
     
    krt, Nov 15, 2007 IP
  6. holyguy2005

    holyguy2005 Member

    Messages:
    93
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    43
    #6
    holyguy2005, Nov 15, 2007 IP