Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Did someone achieve to do negative regexp (or part of) with Squirm ?
I tried negative lookahead things and ifthenelse regexps, but Squirm 1.26 fails to understand them.

What i want to do is simply:
* If the url begins by 'http://' and contains 'account', then rewrite/redirect to 301:https://
* It the url begins by 'https://' and does NOT contains 'account, then rewrite/redirect to 301:http://

So far, i do that using 2 lines of perl, but squirm redirectors would take less memory

share|improve this question

1 Answer 1

Thanks to Chris Foote, the Squirm owner, i got it working with his trick. Before it did not occur to me that squirm would stop the rewriting once a pattern match

regexi ^(https:\/\/.*\/account.*)$ \1 account
regexi ^http:\/\/(.*\/account.*)$ 301:https://\1 account
regexi ^https:\/\/(.*)$ 301:http://\1 https

.
Chris explained me how to deal in this situation:

What I've done previously to bypass a general catch-all rewrite rule is to place a rule matching the thing you don't want redirected beforehand, just replaying the original URL without a 301 redirect. e.g.:

regexi (some_pattern) \1       # let through URL unwritten
regexi (http://mydomain/all-to-one-page\.html) \1 # allow \
      direct access to redirect page in the rule below.
regexi .* 301:http://mydomain/all-to-one-page.html  # all \
      other requests get redirected to a single page.
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.