htaccess hel to change qry string to /xx/yy &redirect specific dirs to ssl & nonssl

Discussion in 'Apache' started by rob_v, Aug 18, 2010.

  1. #1
    Hello,
    Im hoping someone can help me out.
    I seem to be going backwards with this problem.

    Here is what Im trying to accomplish.
    1. Parse my qry string to allow action/var1/value1/var2/value2 format in the URL.

    2. redirect non-www to www

    3. redirect specifc actions to https

    4. redirect everything else to http

    I have 1,2, & 3 completed. Im having a real issue with 4.

    So right now - My htaccess file looks like this :

    Options +FollowSymLinks
    RewriteBase /
    RewriteEngine On



    # Redirect non-www to www
    RewriteCond %{HTTP_HOST} !^www\. [NC]
    RewriteRule (.*) http://www.%{HTTP_HOST}/$1 [R=301,L]

    # SSL
    RewriteCond %{HTTPS} !=on
    RewriteRule ^account/(.+)?$ "https://%{HTTP_HOST}/account/$1" [R=301,L]

    RewriteCond %{HTTPS} !=on
    RewriteRule ^signup/(.+)?$ "https://%{HTTP_HOST}/signup/$1" [R=301,L]

    RewriteCond %{HTTPS} !=on
    RewriteRule ^landing_page_signup_form/(.+)?$ "https://%{HTTP_HOST}/landing_page_signup_form/$1" [R=301,L]

    #parse out qry string
    RewriteCond %{SCRIPT_FILENAME} !-f
    RewriteCond %{SCRIPT_FILENAME} !-d
    RewriteRule ^([a-z0-9_]+(/.*)?)$ index.php?mr=_a/$1 [NC,QSA,L]

    Can someone please help redirect everything else to normal http?

    So if someone types in https://www.example.com/testing/var1/one/var2/two - it will redir to http://www.example.com/testing/var1/one/var2/two

    Im trying something like this :
    RewriteCond %{SERVER_PORT} !^80$
    RewriteCond %{REQUEST_URI} !^/?(account|signup|landing_page_signup_form|fb_signup)(.*)
    RewriteRule .? "http://%{HTTP_HOST}/%{REQUEST_URI}" [R,L]
    But thats just not working.

    Been pulling my hair out for a while - any help would be great!
     
    rob_v, Aug 18, 2010 IP