Set RewriteBase to the current folder path dynamically

Here is one way one can grab the RewriteBase in an environment variable which you can then use in your other rewrite rules: RewriteCond %{REQUEST_URI}::$1 ^(.*?/)(.*)::\2$ RewriteRule ^(.*)$ – [E=BASE:%1] Then you can use %{ENV:BASE} in your rules to denote RewriteBase, i.e.: #redirect in-existent files/calls to index.php RewriteCond %{REQUEST_FILENAME} !-f RewriteRule . %{ENV:BASE}/index.php [L] Explanation: … Read more

sed join lines together

sed ‘:a;/0$/{N;s/\n//;ba}’ In a loop (branch ba to label :a), if the current line ends in 0 (/0$/) append next line (N) and remove inner newline (s/\n//). awk: awk ‘{while(/0$/) { getline a; $0=$0 a; sub(/\n/,_) }; print}’ Perl: perl -pe ‘$_.=<>,s/\n// while /0$/’ bash: while read line; do if [ ${line: -1:1} != “0” … Read more

Random Text generator based on regex [duplicate]

Yes, software that can generate a random match to a regex: Exrex, Python Pxeger, Javascript regex-genex, Haskell Xeger, Java Xeger, Python Generex, Java rxrdg, C# String::Random, Perl regldg, C paggern, PHP ReverseRegex, PHP randexp.js, Javascript EGRET, Python/C++ MutRex, Java Fare, C# rstr, Python randexp, Ruby goregen, Go bfgex, Java regexgen, Javascript strgen, Python random-string, Java … Read more

What does ‘\K’ mean in this regex?

Since not all regex flavors support lookbehind, Perl introduced the \K. In general when you have: a\Kb When “b” is matched, \K tells the engine to pretend that the match attempt started at this position. In your example, you want to pretend that the match attempt started at what appears after the “access_token”:” text. This … Read more