私はこれについてのstackoverflowページと非stackoverflowサイトの束を見て、たくさんのことを試しました。何も働いていません。ルートドメインのみをリダイレクトし、すべてのワイルドカードサブドメインを無視するにはどうすればよいですか?
example.comに行くにはmy-example.netが必要です。example.comに行くにはwww.my-example.netが必要です。私はallothersubdomainsthatarenotwww.my-example.netを無視してリダイレクト。私は将来、特定の他のサブドメインを除外したいかもしれません。そのため、1つの試みに4つのサブドメイン例外がありますが、今はwww以外のすべてのサブドメインを無視することに集中しましょう。 wwwとnon-wwwは別のドメインに移動する必要があります。私たちが残りの経路をそのままにしておくことができれば、2番目のドメインのルートに行くのはいいです。例えば:あなたが知っているだけのよう
http://my-example.net/some/path/file.php?parameter=value can go to http://example.com/some/path/file.php?parameter=value,
but if it's to difficult with wildcard subdomains, then going to http://example.com/ is fine.
、私はワイルドカードは、特定の方法をサブドメインとそれが正常に動作扱う場所で他のルールを持っています。いくつかの試みはうまくいくようですが、私がサブドメインに持つ他のルールセットを破ります。たとえば、私はanysubdomain.my-example.netがmy-example.net/folder/file.php?anysubdomainに行くとしましょう。& domain = my-example.net ...次に、以下の試みのどれか1つまたはいくつかを行いますサブドメインがこれを行うのは私の望むものではありません。example.com/folder/file.php?anysubdomain & domain = example.com
サブドメインは、長いパスとメインドメインを持つ自分のドメインにリダイレクトする必要がありますそして、サブドメインがセカンダリドメイン(とやパスの残りの部分を保存せず)にリダイレクトする必要がありますWWWここ
は私の試みです(各ラインのスペースは、新たな試みを意味するが、カップルの試みでは、コメントを解除する必要があり、すべての行ではありません - 私は試行のバリエーションを試していた):
#RewriteCond %{HTTP_HOST} ^[^.]+\.[^.]+$
#RewriteRule ^(.*)$ http://%{HTTP_HOST}/$1 [L,R=301]
#RewriteCond %{HTTP_HOST} ^my-example\.net$
#RewriteRule ^(.*)$ http://example.com/$1 [L,QSA,R=301]
#RewriteCond %{HTTP_HOST} ^my-example\.net$ [NC]
#RewriteRule ^. http://example.com/ [L,R=302]
#RewriteCond %{HTTP_HOST} ^(my-example\.net)$ [NC]
#RewriteRule ^. http://example.com/ [L,R=302]
#RewriteCond %{HTTP_HOST} my-example\.net [NC]
#RewriteCond %{REQUEST_URI} ^/$
#Rewriterule ^(.*)$ http://example.com/ [L,R=301]
#RewriteCond %{HTTP_HOST} !^www\.example\.com [NC]
#RewriteCond %{HTTP_HOST} !^$
#RewriteRule ^/?(.*) http://example.com/$1 [L,R,NE]
#RewriteCond %{HTTP_HOST} ^my-example\.net$ [NC]
#RewriteCond %{HTTP_HOST} !^(.+)\.my-example\.net$ [NC]
#RewriteRule ^(.*)$ http://example.com/$1 [L,QSA,R=301]
#RewriteCond %{HTTP_HOST} !^www
#RewriteRule .? http://www.%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
#RewriteCond %{REQUEST_URI} ^(application|system)
#RewriteRule .? index.php?/%{REQUEST_URI} [L]
#RewriteCond %{REQUEST_FILENAME} !-f
#RewriteCond %{REQUEST_FILENAME} !-d
#RewriteRule .? index.php?/%{REQUEST_URI} [L]
#RewriteCond %{HTTP_HOST} ^www\.my-example\.net$
#RewriteCond %{HTTP_HOST} ^www\.my-example\.net$ [OR]
#RewriteCond %{HTTP_HOST} ^my-example\.net$
#RewriteRule^http://example.com%{REQUEST_URI} [R=301,L,NE]
# Extract the subdomain part of domain.com
#RewriteCond %{HTTP_HOST} ^((?!www)[^.]+)\.my-example\.net$ [NC]
# Check that the subdomain part is not www, dev, old, or new
#RewriteCond %1 !^(www|dev|old|new)$ [NC]
# Redirect all requests to the original url /blog
#RewriteRule ^.*$ /%1 [L]