**http://abc.com**のアクセスを
**http://www.abc.com**にリダイレクトする方法について質問があります。
/var/www/abc.com/public_html/
にindex.htmlやその他jsファイルなどがあります。
/var/www/abc.com/
に**.htaccess**を置き、内容は
RewriteEngine on RewriteCond %{HTTP_HOST} ^abc.com RewriteRule ^(.*)$ http://www.abc.com/$1 [R=301,L]
このようにしました。
しかし、これで**http://abc.com**にアクセスするとなぜか**http://www.abc.com/public_html/**にリダイレクトされてしまいます。
public_htmlというサブディレクトリは設定していないので、404 Not Found と表示されます。
因みに/etc/httpd/conf.d/virtualhost.confは下記の通りです。
`
<VirtualHost *:80>
ServerName abc.com
DocumentRoot "/var/www/abc.com/public_html"
DirectoryIndex index.html
ErrorLog /var/log/httpd/abc.com_error_log
CustomLog /var/log/httpd/abc.com_access_log combined
AddDefaultCharset UTF-8
<Directory "/var/www/abc.com/public_html">
AllowOverride All
</Directory>
</VirtualHost>
<VirtualHost *:80>
ServerName www.abc.com
DocumentRoot "/var/www/abc.com/public_html"
DirectoryIndex index.html
ErrorLog /var/log/httpd/abc.com_error_log
CustomLog /var/log/httpd/abc.com_access_log combined
AddDefaultCharset UTF-8
<Directory "/var/www/abc.com/public_html">
AllowOverride All
</Directory>
</VirtualHost>
`
現在はどちらも同じファイルを表示するようにしています。
ドットインストールなどを参考に見よう見まねで作ってきたので、色々とおかしい部分があると思います。
何かありましたら是非アドバイス頂けると嬉しいです。
回答2件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2014/12/31 03:02