LoginSignup
18
21

More than 5 years have passed since last update.

【FuelPHP ver1.7.1】URLのindex.phpを取る

Posted at

URLのindex.phpを取る

通常のURL: http://example.jp/プロジェクト名/index.php/コントローラ名/アクション名/パラメータ
設定後のURL: http://example.jp/プロジェクト名/コントローラ名/アクション名/パラメータ

設定は下記2点の修正が必要です。
fuel/app/config/config.php
public/.htaccess

fuel/app/config/config.php

FuelPHPはver1.7.1です。
既にFuelPHP側に用意されていて、下記のindex_file部分のコメントを取る。

 * Set this to 'index.php if you don't use URL rewriting
 */
- //'index_file' => false,
+ 'index_file' => false,

プロジェクト名/public/.htaccess

既にFuelPHP側に用意されていて、下記のコメントを取る。

  #Remove index.php from URL
- #RewriteCond %{HTTP:X-Requested-With} !^XMLHttpRequest$
- #RewriteCond %{THE_REQUEST}               ^[^/]*/index\.php [NC]
- #RewriteRule ^index\.php(.*)$         $1 [R=301,NS,L]

+ RewriteCond %{HTTP:X-Requested-With}  !^XMLHttpRequest$
+ RewriteCond %{THE_REQUEST}                ^[^/]*/index\.php [NC]
+ RewriteRule ^index\.php(.*)$          $1 [R=301,NS,L]

各ディレクトリの.htaccessを有効にするためApacheの設定を確認 or 変更する。

/etc/httpd/conf/httpd.conf
AllowOverride をNONEであればALLにする。
ALLにする事でディレクトリ単位で制御するhtaccessが有効になる。

Apacheを再起動する

service httpd restart

FuelPHP ver1.7.1ではindex.phpを取る設定が既にコメントで用意されているから楽だぁーー

18
21
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
18
21