LoginSignup
0
0

More than 5 years have passed since last update.

(httpd)クエリ文字列を受け付けないようにする

Last updated at Posted at 2017-05-01

httpdの設定メモ

例えば、
https://example.jp/
というサイトに対し
https://example.jp/?query=1
のようなGETパラメータを受け付けないようにするため、TOPページの
https://example.jp/
にリダイレクトするように設定する。

<VirtualHost *:443>
    ServerName example.jp
    DocumentRoot /var/www/dev-hoge
    <IfModule mod_rewrite.c>
        RewriteEngine On
        RewriteCond %{QUERY_STRING} .+
        RewriteRule ^ https://example.jp/? [R=301,L]
    </IfModule>
...

※Rewriteルールだけではクエリ文字列を判定しないので、RewriteCondでQUERY_STRINGを指定する。

※RewriteRuleのリダイレクト先の最後に?を追加しないとリダイレクトループが発生してしまう。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0