domain.com/otherdomain.com .htaccess

Discussion in 'Apache' started by kreoton, Mar 8, 2007.

  1. #1
    I'm new to mod rewrite but how i should make this work? I use shown code but then in address bar i type domain.com/otherdomain.com it shows 404 error :confused:

    RewriteEngine On
    RewriteRule /$1 index.php?url=$1
    Code (markup):
     
    kreoton, Mar 8, 2007 IP
  2. rodney88

    rodney88 Guest

    Messages:
    480
    Likes Received:
    37
    Best Answers:
    0
    Trophy Points:
    0
    #2
    I'm not sure what you're trying to do - rewrite every page to your index script?

    The first $1 contains nothing. If you're putting this in the root of your domain, you also shouldn't need the first slash.

    If your rewriterule contains a regex expression, you can surround bits of the expression with parenthesis and this will capture the match into a backreference of the form $N. For the pattern, its standard regex - in this case you want to match everything.
    RewriteRule ^(.*)$ index.php?url=$1 [L,QSA]
    Code (markup):
    I've also included the Query String Append (QSA) flag - so domain.com/file.php?var=val will get rewritten to index.php?url=file.php&var=val.

    Hopefully that helps a bit..
     
    rodney88, Mar 8, 2007 IP
  3. kreoton

    kreoton Peon

    Messages:
    229
    Likes Received:
    7
    Best Answers:
    0
    Trophy Points:
    0
    #3
    kreoton, Mar 8, 2007 IP