Advertisement
Help Keep Boards Alive. Support us by going ad free today. See here: https://subscriptions.boards.ie/.
https://www.boards.ie/group/1878-subscribers-forum

Private Group for paid up members of Boards.ie. Join the club.
Hi all, please see this major site announcement: https://www.boards.ie/discussion/2058427594/boards-ie-2026

Qs about rewrite syntax

  • 08-01-2014 02:12PM
    #1
    Registered Users, Registered Users 2 Posts: 81,060 ✭✭✭✭


    I am just getting into rewriting (part of a project at work I'm involved in) and have a httpd.conf file I've been looking at

    A lot of the rules are written way before my time and the devs have moved to other companies. I've asked new devs about the syntax but they aren't sure so I thought I'd throw it up here in case someone will know better.
    This is the first of a few conds/rules I am curious about:

    RewriteCond %{HTTPS} (on)?
    RewriteCond %{HTTP_HOST} ^example.com [NC]
    RewriteRule ^/(.*) http(?%1s)://www.example.com/$1 [R=301,L]

    The first cond turns off https but what is the bracketed (on) and question mark for? Should it not just be RewriteCond %{HTTPS} on
    Also, the rule ^/(.*) is greedy and should capture example.com/justaboutanything

    What is the (?%1s) used for?
    $1 is filled from ^/(.*) yeah? And doesn't this mean a QSA is needed?


Comments

Advertisement