私の .htaccess ファイルはルートにあり、複数の Web サイトにサービスを提供しています。
RewriteEngine ブロックが含まれています。
ホストが (www) www.example.com でない場合、Apache がルールを評価するのを防ぎたい:
RewriteEngine On
RewriteBase /
#If this is not about example.com, it is probably about our other websites, exit here
RewriteRule %{HTTP_HOST} !^(www|)example.com$ - [L]
ただし、これにより 500 内部エラーが発生します。おそらく {HTTP-HOST} の使用が RewriteRule ディレクティブであるためです。
そこで今、次のようなことを考えています。
RewriteCond %{HTTP_HOST} !^(www|)example.com
RewriteRule (.*) $1 [L]
しかし、これには Apache の書き直しが必要であり、パフォーマンスが低下します。
誰でも提案はありますか?