我正在嘗試使用PHP & MySQL在本地構建購物車。我的主要目錄是/ Library/WebServer/Documents。我試圖設置它,以便我可以在沒有index.php的情況下訪問localhost/project。codeigniter - 我的htaccess有什麼問題?
這裏是我的htaccess:
Options +FollowSymLinks
Options -Indexes
DirectoryIndex index.php
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond $1 !^(index\.php|resources|images|css|js|robots\.txt|favicon\.ico)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L,QSA]
</IfModule>
<IfModule !mod_rewrite.c>
ErrorDocument 404 /index.php
</IfModule>
我的配置代碼(提取,而不是整個事情):
$config['base_url'] = 'http://localhost/project/';
$config['index_page'] = '';
$config['uri_protocol'] = 'REQUEST_URI';
顯然有這個錯誤。即使我設法訪問本地主機/項目沒有index.php,我無法查看由我的控制器代碼生成的頁面(例如,如果我嘗試去本地/項目/歡迎我得到這個錯誤消息:'請求的URL /項目/歡迎在此服務器上找到。」本地主機/項目/歡迎應該帶我去的welcome.php網頁在我的控制器文件夾。
Here's a snapshot of the file structure
有人能向我解釋什麼是錯我的代碼?
通常情況下,你不會有''在目錄views'文件.htaccess'。至少在安裝新的CI時沒有這樣的文件。 – Tpojka
@vnguyen你需要從URL刪除index.php? –