Mod-rewrite help?

Discussion in 'Programming' started by m30, Nov 20, 2009.

  1. #1
    m30, Nov 20, 2009 IP
  2. m30

    m30 Guest

    Messages:
    116
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #2
    How can i set a condition which checks if the url is NOT the root URl.

    I tried this and It doesnt work:
    RewriteCond %{http_host} !^http://www.site.com/ [nc]

    Suggestions?

    Thanks!
     
    m30, Nov 20, 2009 IP
  3. chadsmith

    chadsmith Peon

    Messages:
    82
    Likes Received:
    6
    Best Answers:
    0
    Trophy Points:
    0
    #3
    To see if the URL is not on the root domain you have to do it without the http:// so that condition would be:

    RewriteCond %{HTTP_HOST} !^www\.site\.com$
    Code (markup):
    You can redirect the user names by adding:

    RewriteRule ^([a-z]+)$ /profile.php?user=$1 [L]
    Code (markup):
    After the other rules.
     
    chadsmith, Nov 20, 2009 IP
  4. m30

    m30 Guest

    Messages:
    116
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #4
    Ok it's not working, here is my code:

    RewriteCond $1 !^home
    RewriteCond $1 !^about
    RewriteCond $1 !^signup
    RewriteCond $1 !^contact
    RewriteCond $1 !^signin
    RewriteCond $1 !^index2\.php
    RewriteCond %{HTTP_HOST} !^www\.site\.me$
    RewriteRule ^([^/]+)$ profile.php?user=$1 [L]



    When I add the last condition, www.site.me/FOO , shows a 404 not found, instead of the contents of the profile.php file. Any help very much appreciated,

    Jake.
     
    m30, Nov 21, 2009 IP
  5. m30

    m30 Guest

    Messages:
    116
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #5
    I believe the problem is that the condition is www.site.me AND anything which is following this. However I only want it to limit it to the root domain, when the URI is www.site.me

    thanks
     
    m30, Nov 21, 2009 IP