LoginSignup
2
2

More than 3 years have passed since last update.

【concrete5】『さくらのレンタルサーバ』で、www付きのドメイン名でのみアクセス出来るようにする

Last updated at Posted at 2016-03-04

さくらのレンタルサーバで独自ドメインを設定した際、標準では
http://tagworks.jp/
http://www.tagworks.jp/
上記どちらのURLでもアクセス可能です。

wwwなしのURLで統一したい時はコントロールパネルから設定が出来るのですが、www付きURLで統一したい場合は、下記にある通りmod_rewriteの設定が必要になります。

『wwwというホスト名の有無を統一する(上級者向け)』
https://help.sakura.ad.jp/app/answers/detail/a_id/2332/~/www%E3%81%A8%E3%81%84%E3%81%86%E3%83%9B%E3%82%B9%E3%83%88%E5%90%8D%E3%81%AE%E6%9C%89%E7%84%A1%E3%82%92%E7%B5%B1%E4%B8%80%E3%81%99%E3%82%8B(%E4%B8%8A%E7%B4%9A%E8%80%85%E5%90%91%E3%81%91)

ただ、concrete5でプリティーURLを設定した場合もmod_rewriteが設定されますので、『URLをwww付きで統一』かつ
『concrete5のプリティURL設定』という設定が両立可能か検証してみました。

.htaccess
        # -- concrete5 urls start --
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} ^(tagworks\.jp)$ [NC]
RewriteRule (.*) http://www.tagworks.jp%{REQUEST_URI} [R=301,L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME}/index.html !-f
RewriteCond %{REQUEST_FILENAME}/index.php !-f
RewriteRule . index.php [L]
</IfModule>
        # -- concrete5 urls end --

Gist:
https://gist.github.com/kanetei/9fc7316259b9707afa0a

上記設定で、

と、問題なさそうなので、どちらの設定も両立出来ているようです。
(mod_rewriteの設定に明るくないので、これで本当に問題ないか自信がないですが……)

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