LoginSignup
1
1

More than 5 years have passed since last update.

www.example.comをexample.comにリダイレクトする

Posted at

今回は.htaccessをいじりました。

RewriteEngine on
RewriteCond %{HTTP_HOST} ^www\.example\.com(:80)?
RewriteRule ^(.*) http://example.com/$1 [R=301,L]

RewriteRuleの第一引数に"/"を入れるとリダイレクトされなかった。

RewriteRule ^/(.*) http://example.com/$1 [R=301,L]

RewriteRuleの第三引数で"R=301,"と"L"の間にスペースを入れたらエラーになった。

RewriteRule ^(.*) http://example.com/$1 [R=301, L]

参考: http://httpd.apache.org/docs/current/mod/mod_rewrite.html

1
1
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
1
1