コマンドラインで「.htaccess」をテストする方法

コマンドラインで「.htaccess」をテストする方法

Apache間欠的にはならない原因を探そうとします。インターネットサーバーエラーMediaWikiの編集とアップロード中。一部の情報源では、エラーを確認するように言います.htaccess

以下で確認できます.htaccess

sudo find /var -name '.htaccess' -exec ls -al {} \;

しかし、このファイルをテストするためのApacheコマンドが何であるかわかりません.htaccess。つまり、-execセクションに何を挿入するのかわかりませんfind

私はこれを見apachectlてみましたが、行き止まりapachectl testの路地のように見えます。

$ apachectl test
Usage: /usr/sbin/httpd [-D name] [-d directory] [-f file]
                       [-C "directive"] [-c "directive"]
                       [-k start|restart|graceful|graceful-stop|stop]
                       [-v] [-V] [-h] [-l] [-L] [-t] [-T] [-S] [-X]
Options:
  -D name            : define a name for use in <IfDefine name> directives
  -d directory       : specify an alternate initial ServerRoot
  -f file            : specify an alternate ServerConfigFile
  -C "directive"     : process directive before reading config files
  -c "directive"     : process directive after reading config files
  -e level           : show startup errors of level (see LogLevel)
  -E file            : log startup errors to file
  -v                 : show version number
  -V                 : show compile settings
  -h                 : list available command line options (this page)
  -l                 : list compiled in modules
  -L                 : list available configuration directives
  -t -D DUMP_VHOSTS  : show parsed vhost settings
  -t -D DUMP_RUN_CFG : show parsed run settings
  -S                 : a synonym for -t -D DUMP_VHOSTS -D DUMP_RUN_CFG
  -t -D DUMP_MODULES : show all loaded modules 
  -M                 : a synonym for -t -D DUMP_MODULES
  -t                 : run syntax check for config files
  -T                 : start without DocumentRoot(s) check
  -X                 : debug mode (only one worker, do not detach)

SSH経由でボックスにアクセスでき、これがメンテナンスを実行する方法です。利用可能なブラウザはありませんが、必要に応じてlynxを使用できます。

.htaccessコマンドラインで以下に示すさまざまな項目をどのようにテストできますか?


$ sudo find /var -name '.htaccess' -exec ls -l {} \;
-rw-r----- 1 root apache 180 Aug  9  2015 /var/www/html/wiki/images/.htaccess
-rw-r----- 1 root apache 14 Aug  9  2015 /var/www/html/wiki/images/deleted/.htaccess
-rw-r----- 1 root apache 14 May 25  2015 /var/www/html/wiki/languages/.htaccess
-rw-r----- 1 root apache 14 May 25  2015 /var/www/html/wiki/serialized/.htaccess
-rw-r----- 1 root apache 14 May 25  2015 /var/www/html/wiki/cache/.htaccess
-rw-r----- 1 root apache 14 May 25  2015 /var/www/html/wiki/includes/.htaccess
-rw-r----- 1 root apache 14 May 25  2015 /var/www/html/wiki/maintenance/archives/.htaccess
-rw-r----- 1 root apache 14 May 25  2015 /var/www/html/wiki/maintenance/.htaccess
-rw-r----- 1 root apache 180 Aug  9  2015 /var/www/html/.htaccess

$ apachectl -v
Server version: Apache/2.4.6 (CentOS)
Server built:   May 12 2016 10:27:23

ベストアンサー1

コマンドラインで.htaccessをテストする方法は?

コマンドラインでHTTPリクエストを使用しないのとまったく同じです。

curl(これに限定されない)など、これに役立ついくつかの一般的なツールがありますwget。両方のツールには、ヘッダー、HTTPリターンコード、および完全な出力を取得するオプションが含まれています。

これを自動検索に統合する必要がある場合は、次のように単純なテキスト置換またはマッピングを実行する必要があります。

basename `dirname /var/www/www.mysite.com/public`

...出力:

www.mysite.com

あなたの意見に基づいて実際のパスを見せてください...

echo www.yoursite.com/`dirname /var/www/html/wiki/serialized/.htaccess|cut -d/ -f5-`

...次を提供します:

www.yoursite.com/wiki/serialized

したがって、最終コマンドは次のようになります。

wget $(echo www.yoursite.com/`dirname /var/www/html/wiki/serialized/.htaccess|cut -d/ -f5-`)

おすすめ記事