作者arthas1107 (az)
看板PHP
標題[請益]CodeIgniter 開啟mod_rewrite失敗
時間Fri Jul 15 18:14:36 2016
已爬文但仍然無法解決,只好再發一篇請大家幫忙
環境
Win10
apache 2.4.20 x86
php 5.6.22 x86
CI2.1.2
架構
WWW
/test
/index.php、.htaccess、system、application...
修改項目
apache-httpd.conf
155行
LoadModule rewrite_module modules/mod_rewrite.so 刪除註解
226行
<Directory />
AllowOverride All
Require all denied
</Directory>
244行
<Directory "d:/www">
Options MultiViews
AllowOverride All
Require all granted
</Directory>
ci-conf
$config['index_page'] = '';
.htaccess內容
RewriteEngine On
RewriteBase /test
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]
網路上查到的做法大都試過了,但是仍出現錯誤訊息
Forbidden
You don't have permission to access /test/index.php on this server.
麻煩大家看一下我有哪邊做錯了,感謝
--
※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 118.232.112.210
※ 文章網址: https://www.ptt.cc/bbs/PHP/M.1468577678.A.3F3.html
→ MOONRAKER: 如果你確定找到的方法都做了 檢查.htaccess的換行字元07/15 21:06
→ MOONRAKER: 不可以CRLF 要轉成LF07/15 21:07
→ MOONRAKERm: Sorry 沒看到在win10下 那恐怕跟CRLF沒關聯 07/15 21:08
推 ns1234: W10..真酷07/15 21:10
推 ns1234: 照錯誤訊息看是 是權限問題 apache 不能訪問 test資料夾?07/15 21:14
→ ns1234: 根目錄下的index.php 能開嗎07/15 21:15
在網址裡加上index.php就正常顯示,但是拿掉就會出現沒有權限的訊息,會是Options MultiViews這設定問題嗎?
※ 編輯: arthas1107 (118.171.135.62), 07/15/2016 22:36:07
※ 編輯: arthas1107 (118.171.135.62), 07/15/2016 22:37:41
推 ns1234: 不負責任猜測是少了一個 "." ,變成導到硬碟的"/test/index 07/16 02:06
→ ns1234: 應該是要導到 /var/www/html/test/index.php 之類的 07/16 02:07
推 ns1234: 查了一下我的猜測應該是錯的 別理我.. 07/16 02:22
推 ns1234: 另外想問一下 CI有3 不直接 從3開始嗎XD 07/16 02:27
→ AkiHito: 這是用sub folder的? 07/16 07:11
因為是抓範例來研究的,提供者是用2,剛剛測試確實是權限問題
改成Options FollowSymLinks就可以了,感謝大家提供意見
※ 編輯: arthas1107 (118.232.112.210), 07/16/2016 15:39:32