FuelPHP URLからindex.phpを消したいのですがうまくいきません。
設定した事として、
/var/www/に
.htaccessに次のコードを書きました。
lang
1<IfModule mod_rewrite.c> 2RewriteCond %{REQUEST_FILENAME} !-f 3RewriteCond %{REQUEST_FILENAME} !-d 4RewriteCond %{REQUEST_URI} !=/favicon.ico 5RewriteRule ^ /index.php [L] 6</IfModule>
またこれをfuleをインストールしたディレクトリにも.htaccessを作りました。
さらに、config.phpの
次に fuel/app/config/config.php を下記のように編集します。
'index_file' => false,
としたのですが、URLからindex.phpが消えません。
何かアドバイス頂けますでしょうか?
サーバーはUbutnuです。
気になる質問をクリップする
クリップした質問は、後からいつでもMYページで確認できます。
またクリップした質問に回答があった際、通知やメールを受け取ることができます。
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
回答4件
0
fuelPHPのバージョンはいくつでしょうか?
1.7以上ならデフォルトで、index.phpを消す設定になっているので
入れれなおしてみればできると思うけど・・・
FuelPHP1.7のインストール
提示された.htaccess
で試して、確かにエラーになったけど
1.7の.htaccess
で上書きしたらindexが消えて動作はしました。
1.7のpublic/.htaccess
は↓
lang
1# Multiple Environment config, set this to development, staging or production 2# SetEnv FUEL_ENV production 3 4<IfModule mod_rewrite.c> 5 6 RewriteEngine on 7 8 # NOTICE: If you get a 404 play with combinations of the following commented out lines 9 #AllowOverride All 10 #RewriteBase /wherever/fuel/is 11 12 # Make sure directory listing is disabled 13 Options +FollowSymLinks -Indexes 14 15 # Restrict your site to only one domain 16 # !important USE ONLY ONE OPTION 17 18 # Option 1: To rewrite "www.domain.com -> domain.com" uncomment the following lines. 19 #RewriteCond %{HTTPS} !=on 20 #RewriteCond %{HTTP_HOST} ^www.(.+)$ [NC] 21 #RewriteRule ^(.*)$ http://%1/$1 [R=301,L] 22 23 # Option 2: To rewrite "domain.com -> www.domain.com" uncomment the following lines. 24 #RewriteCond %{HTTPS} !=on 25 #RewriteCond %{HTTP_HOST} !^www..+$ [NC] 26 #RewriteCond %{HTTP_HOST} (.+)$ [NC] 27 #RewriteRule ^(.*)$ http://www.%1/$1 [R=301,L] 28 29 # Remove index.php from URL 30 #RewriteCond %{HTTP:X-Requested-With} !^XMLHttpRequest$ 31 #RewriteCond %{THE_REQUEST} ^[^/]*/index.php [NC] 32 #RewriteRule ^index.php(.*)$ $1 [R=301,NS,L] 33 34 # make HTTP Basic Authentication work on php5-fcgi installs 35 <IfModule mod_fcgid.c> 36 RewriteCond %{HTTP:Authorization} . 37 RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}] 38 </IfModule> 39 40 # Send request via index.php if not a real file or directory 41 RewriteCond %{REQUEST_FILENAME} !-f 42 RewriteCond %{REQUEST_FILENAME} !-d 43 44 # deal with php5-cgi first 45 <IfModule mod_fcgid.c> 46 RewriteRule ^(.*)$ index.php?/$1 [QSA,L] 47 </IfModule> 48 49 <IfModule !mod_fcgid.c> 50 51 # for normal Apache installations 52 <IfModule mod_php5.c> 53 RewriteRule ^(.*)$ index.php/$1 [L] 54 </IfModule> 55 56 # for Apache FGCI installations 57 <IfModule !mod_php5.c> 58 RewriteRule ^(.*)$ index.php?/$1 [QSA,L] 59 </IfModule> 60 61 </IfModule> 62 63</IfModule> 64
投稿2014/11/15 05:30
退会済みユーザー
総合スコア0
0
WEBサーバーはapacheでしょうか?
apacheで設定が
AllowOverride All Order deny,allow Allow From all
のようになっていれば動くと思います。
nginxを利用している場合.htaccessで行っている設定をnginxの設定ファイル内で行う必要があったと思います。
またFUELPHPのpublicにデフォルトである.htaccessは以下のようだったと思います。
# Multiple Environment config, set this to development, staging or production # SetEnv FUEL_ENV production php_value short_open_tag 1 <IfModule mod_rewrite.c> # Make sure directory listing is disabled Options +FollowSymLinks -Indexes RewriteEngine on # NOTICE: If you get a 404 play with combinations of the following commented out lines #AllowOverride All #RewriteBase /wherever/fuel/is RewriteBase / # Restrict your site to only one domain # !important USE ONLY ONE OPTION # Option 1: To rewrite "www.domain.com -> domain.com" uncomment the following lines. #RewriteCond %{HTTPS} !=on #RewriteCond %{HTTP_HOST} ^www.(.+)$ [NC] #RewriteRule ^(.*)$ http://%1/$1 [R=301,L] # Option 2: To rewrite "domain.com -> www.domain.com" uncomment the following lines. #RewriteCond %{HTTPS} !=on #RewriteCond %{HTTP_HOST} !^www..+$ [NC] #RewriteCond %{HTTP_HOST} (.+)$ [NC] #RewriteRule ^(.*)$ http://www.%1/$1 [R=301,L] # 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] # Send request via index.php (again, not if its a real file or folder) RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d # deal with php5-cgi first <IfModule mod_fcgid.c> RewriteRule ^(.*)$ index.php?/$1 [QSA,L] </IfModule> <IfModule !mod_fcgid.c> # for normal Apache installations <IfModule mod_php5.c> RewriteRule ^(.*)$ index.php/$1 [L] </IfModule> # for Apache FGCI installations <IfModule !mod_php5.c> RewriteRule ^(.*)$ index.php?/$1 [QSA,L] </IfModule> </IfModule> </IfModule>
ちなみに
具体的には
http://example.com/blog/public/index.php/article/
を
http://example.com/blog/public/article/
のようにしたいです。
とのことですが
現在では
http://example.com/blog/public/article/
だとエラーになってしまう状態でしょうか?
投稿2014/11/13 07:19
総合スコア64
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
0
FuelPHPのpublic/.htaccessの修正が必要だと思います。
新し目のFuelPHPであればコメントアウト状態ですでに用意されているのではないかと思います。
投稿2014/11/13 00:10
総合スコア1356
あなたの回答
tips
太字
斜体
打ち消し線
見出し
引用テキストの挿入
コードの挿入
リンクの挿入
リストの挿入
番号リストの挿入
表の挿入
水平線の挿入
プレビュー
質問の解決につながる回答をしましょう。 サンプルコードなど、より具体的な説明があると質問者の理解の助けになります。 また、読む側のことを考えた、分かりやすい文章を心がけましょう。
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。