LoginSignup
1
2

More than 5 years have passed since last update.

FuelPHP URLの /index.php 排除!

Last updated at Posted at 2016-04-13

はじめに

改訂FuelPHP入門を勉強したいと思い、 やるぞー! と始めたのですが・・・

http://localhost/blog/public/index.php/welcome
/index.phpを取り除いた
http://localhost/blog/public/welcome

でアクセスしたいのに404が返ってくる問題に直面したので、
またFuelPHPをインストールしたらすぐ開発できるようにメモします!!!

※ちなみにFuelPHPのversionは1.7です。
※http://localhost/blog/public/index.php/welcome 
※このURLのblogと書いてある部分は自身のプロジェクト名です。

index_fileをfalseに。

config.phpファイルに変更すべきところがあるので、

APPPATH/config/config.php
    /**
     * index_file - The name of the main bootstrap file.
     *
     * Set this to 'index.php if you don't use URL rewriting
     */
          // ↓コメントアウトされてるところ!↓
     // 'index_file' => false,

コメントアウトされているので有効にする。

APPPATH/config/config.php
    /**
     * index_file - The name of the main bootstrap file.
     *
     * Set this to 'index.php if you don't use URL rewriting
     */
           // ↓コメントを外してあげる!↓
     'index_file' => false,

httpd.confの設定

※(自分のファイルはここにありました)
/etc/apache2/httpd.conf
<Directory "/Users/naoki/fuelphp/blog/public">
・・・
・・・

    #
    # AllowOverride controls what directives may be placed in .htaccess files.
    # It can be "All", "None", or any combination of the keywords:
    #   AllowOverride FileInfo AuthConfig Limit
    #

    # None になっているところを変更する
    AllowOverride None

・・・
・・・
</Directory>

None になっているところを All に変更する

/etc/apache2/httpd.conf
<Directory "/Users/naoki/fuelphp/blog/public">
・・・
・・・

    #
    # AllowOverride controls what directives may be placed in .htaccess files.
    # It can be "All", "None", or any combination of the keywords:
    #   AllowOverride FileInfo AuthConfig Limit
    #

        # All に変更!
    AllowOverride All

・・・
・・・
</Directory>

最後に

apacheに設定変更を反映させるので、下記のコマンドを実行する。
sudo apachectl restart

コマンド実行したらURLにアクセス!
http://localhost/blog/public/welcome

これで設定完了!

これで動きました。
色々な情報が出ているのでそちらも参考にしつつ設定してみてください!

1
2
5

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
2