htaccess - problems using 2 rewrite conditions

Discussion in 'Apache' started by Investawise, Mar 16, 2011.

  1. #1
    Ok I am trying to do to things on my site.

    Firstly I want anyone going to mysite.com to be redirected to the version with the 'www.'

    Secondly (and this is so I can use different landing pages with Clickbank) I want to redirect anyone who comes to my site with the parameter ?l=2 to be sent to a different page.

    So at the moment I have:

    RewriteEngine On
    RewriteCond %{HTTP_HOST} ^mysite\.com$
    RewriteRule (.*) http://www.mysite.com/$1 [R=301,L]
    RewriteCond %{QUERY_STRING} ^l=2$
    RewriteRule ^(.*)$ http://www.mysite.com/alternative.php? [R=301,L] 
    PHP:
    Both of these codes work individually but as soon as I try and use them both together the whole site goes down. I know virtually nothing about programming and have just picked these bits of code up so perhaps its something obvious but any help would be massively appreciated! :cool:
     
    Investawise, Mar 16, 2011 IP
  2. Investawise

    Investawise Well-Known Member

    Messages:
    514
    Likes Received:
    31
    Best Answers:
    0
    Trophy Points:
    130
    #2
    Ah turns out that code DOES work - I think my cache just wasnt clearing properly.

    But after all that it still doesnt do what I need it to!

    Basically I will have parameters like this:

    ?VARIABLE&l=2

    Where basically the 'VARIABLE' bit changes regularly. So how do I edit the code so that it just looks for the 'l=2' bit on the very end of the variable?
     
    Investawise, Mar 16, 2011 IP
  3. Investawise

    Investawise Well-Known Member

    Messages:
    514
    Likes Received:
    31
    Best Answers:
    0
    Trophy Points:
    130
    #3
    Ah never mind - got a solution from another forum.

    For anyone else who may be interested I used php instead:

     
    Investawise, Mar 16, 2011 IP