Переформатирование Apache RewriteRule

Вы можете сделать это, настроив свой файл ~ / .ssh / ssh_config и используя аутентификацию с открытым ключом. Для каждого сервера, на который вы хотите войти, настройте раздел Host в файле с соответствующими записями User и IdentityFile .

См. man ssh_config для получения дополнительной информации.

1
19.07.2016, 14:12
2 ответа

Я мало что знаю о правилах Apache, так что, вероятно, это перебор. Однако, если слишком много экранирования не является проблемой, вы можете использовать:

$ perl -ne 'print quotemeta()' file
RewriteRule\ \^\/trendy\/the\-reason\-for\-example\ http\:\/\/www\.example\.com\/trendy\/the\-reason\ \[NC\,\ L\,\ R\=301\]\
RewriteRule\ \^\/lol\/2015\/10\.\.\._for\-example\ http\:\/\/www\.example\.com\/lol\/the\-reason\ \[NC\,\ L\,\ R\=301\]\
RewriteRule\ \^\/sports\/this\-one\*\*\*\-as\-well\ http\:\/\/www\.example\.com\/sports\/this\-one\ \[NC\,\ L\,\ R\=301\]\
RewriteRule\ \^\/buzz\/the\-\#reason\-for\-buzz\ http\:\/\/www\.example\.com\/buzz\/buzz\-sells\ \[NC\,\ L\,\ R\=301\]\
RewriteRule\ \^\/omg\/\ what\-the\-hell\ http\:\/\/www\.example\.com\/omg\/wthell\ \[NC\,\ L\,\ R\=301\]\
RewriteRule\ \^\/hash\/HELL\-YEAH\ http\:\/\/www\.example\.com\/hash\/oh\-yes\ \[NC\,\ L\,\ R\=301\]\
RewriteRule\ \^\/celeb\/he\-did\-it\!\ http\:\/\/www\.example\.com\/celeb\/we\-believe\ \[NC\,\ L\,\ R\=301\]\

В противном случае, чтобы экранировать только определенные символы, которые вы упомянули, используйте:

$ sed 's#[*.#!]#\\&#g' file
RewriteRule\ ^/trendy/the-reason-for-example\ http://www\.example\.com/trendy/the-reason\ [NC,\ L,\ R=301]
RewriteRule\ ^/lol/2015/10\.\.\._for-example\ http://www\.example\.com/lol/the-reason\ [NC,\ L,\ R=301]
RewriteRule\ ^/sports/this-one\*\*\*-as-well\ http://www\.example\.com/sports/this-one\ [NC,\ L,\ R=301]
RewriteRule\ ^/buzz/the-\#reason-for-buzz\ http://www\.example\.com/buzz/buzz-sells\ [NC,\ L,\ R=301]
RewriteRule\ ^/omg/\ what-the-hell\ http://www\.example\.com/omg/wthell\ [NC,\ L,\ R=301]
RewriteRule\ ^/hash/HELL-YEAH\ http://www\.example\.com/hash/oh-yes\ [NC,\ L,\ R=301]
RewriteRule\ ^/celeb/he-did-it\!\ http://www\.example\.com/celeb/we-believe\ [NC,\ L,\ R=301]

Чтобы сделать то же самое, но только во втором поле, используйте:

$ perl -lne '/(.+\^)(.*)( http.*)/; ($k,$l,$m)=($1,$2,$3); $l=~s/[ *.#!]/\\$&/g; print "$k$l$m";' file
RewriteRule ^/trendy/the-reason-for-example http://www.example.com/trendy/the-reason [NC, L, R=301]
RewriteRule ^/lol/2015/10\.\.\._for-example http://www.example.com/lol/the-reason [NC, L, R=301]
RewriteRule ^/sports/this-one\*\*\*-as-well http://www.example.com/sports/this-one [NC, L, R=301]
RewriteRule ^/buzz/the-\#reason-for-buzz http://www.example.com/buzz/buzz-sells [NC, L, R=301]
RewriteRule ^/omg/\ what-the-hell http://www.example.com/omg/wthell [NC, L, R=301]
RewriteRule ^/hash/HELL-YEAH http://www.example.com/hash/oh-yes [NC, L, R=301]
RewriteRule ^/celeb/he-did-it\! http://www.example.com/celeb/we-believe [NC, L, R=301]
0
28.01.2020, 01:33

Это будет работать:

sed '' -- *

Вам не нужны контуры оболочки или иначе, и это всегда будет следовать за выводом файла с \n ewline - за исключением, возможно, самого последнего.

В противном случае, если необходимо вывести пустую строку между выводом каждого файла, это может сработать:

bpaste(){
    eval "paste -'sd\n' -- $(x=0;for f do printf "\"\${$((x+=1))}\" - ";done)"
}   </dev/null

Это всегда будет следовать за выводом файла с \n ewline и дополнительной пустой строкой.

Его можно назвать следующим образом:

bpaste *
-121--42728-

Наборы опцией nullglob :

shopt -s nullglob
-121--82024-

Perl:

perl -pe '
  @f = split /\^|\s+http:/;
  $f[1] =~ s{([^\w/-])}{\\\\$1}g;
  $_ = $f[0] . "^" . $f[1] . " http:" . $f[2]
' file
RewriteRule ^/trendy/the-reason-for-example http://www.example.com/trendy/the-reason [NC, L, R=301]
RewriteRule ^/lol/2015/10\.\.\._for-example http://www.example.com/lol/the-reason [NC, L, R=301]
RewriteRule ^/sports/this-one\*\*\*-as-well http://www.example.com/sports/this-one [NC, L, R=301]
RewriteRule ^/buzz/the-\#reason-for-buzz http://www.example.com/buzz/buzz-sells [NC, L, R=301]
RewriteRule ^/omg/\ what-the-hell http://www.example.com/omg/wthell [NC, L, R=301]
RewriteRule ^/hash/HELL-YEAH http://www.example.com/hash/oh-yes [NC, L, R=301]
RewriteRule ^/celeb/he-did-it\! http://www.example.com/celeb/we-believe [NC, L, R=301]

Разделите строку на «^» или «http:», esacape все символы, которые не являются буквами, цифрами, подчеркиванием, косой, косой, гип затем реформировать линию.

0
28.01.2020, 01:33

Теги

Похожие вопросы