LoginSignup
3
6

More than 5 years have passed since last update.

EC-CUBE3 URLを変える (index.php 非表示)

Posted at

2016/06/29筆記

目的

ECーCUBE3で構築したサイトのURLを

http://ホスト名/html/index.php
http://ドメイン名/html/index.php

ではなく

http://ホスト名/
http://ドメイン名/

で表示する。

筆者環境

EC-CUBE : 3.0.9
OS : ubuntu14.04
Apache : 2.4.7
クラウドサーバ : さくら

操作

主な操作は
1. VirtualHostの変更
2. htaccessの設定
3. EC-CUBEのpath.yml変更
4. mod_rewriteの有効

VirtualHostの変更

  1. DocumentRootを /html まで記載
  2. AllowOverrideをAllに設定
  3. DirectoryIndexにindex.phpを設定
<VirtualHost *:80>
        ServerAdmin webmaster@localhost
        DocumentRoot /var/www/html/eccube-3.0.9/html

        ErrorLog ${APACHE_LOG_DIR}/error.log
        CustomLog ${APACHE_LOG_DIR}/access.log combined

        <Directory /var/www/html/eccube-3.0.9/html >
                Options Indexes FollowSymLinks
                AllowOverride All
                Require all granted
                DirectoryIndex index.php
        </Directory>
</VirtualHost>

.htaccessの設定

.htaccessの配置場所
eccube-3.0.9/html/.htaccess

  1. mod_rewriteの設定
order deny,allow
allow from all
<IfModule mod_rewrite.c>
   RewriteEngine On
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !^(.*)\.(gif|png|jpg|css|ico|js)$ [NC]
    RewriteRule ^(.*)$ index.php [QSA,L]
</IfModule>

EC-CUBEのpath.yml変更

path.ymlの配置場所
eccube-3.0.9/app/config/eccube/path.yml
基本的に /htmlの部分を消しこんでいく
変更したところだけ変更後を記載

# duplicated
root: / # root_urlpath
# admin_dir:は変更しない
tpl: /user_data/packages/default/ # front_urlpath
admin_tpl: /user_data/packages/admin/ # admin_urlpath
image_path: /upload/save_image/ # image_save_urlpath
# base valiables
root_urlpath: / # root_urlpathのみ変更
# urlpath
admin_urlpath: /template/admin
front_urlpath: /template/default
image_save_urlpath: /upload/save_image
image_temp_urlpath: /upload/temp_image
user_data_urlpath: /user_data

mod_rewriteの有効

mod_rewriteが有効になっていれば不要

a2enmod rewrite

を実行して、 Module rewrite already enabled と出れば多分大丈夫。

Enabling module rewrite.
To activate the new configuration, you need to run:
  service apache2 restart

こんなメッセージが出たらApacheを再起動して完了。

以上。

参考ページ

Ubuntu版Apache2でmod_rewriteを有効にする
http://qiita.com/u-akihiro/items/c7a5bb38c34858d00c2a

3
6
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
3
6