使用 codeigniter 在撰寫 application 時,若是一直得到 404 Page Not Found 的訊息。
可以檢查
- application 下的 .htaccess
是不是有寫rewrite 過
/var/www/ci
這樣網址可以直接打 http://localhost/ci/<view>
<IfModule mod_rewrite.c>
RewriteEngine On
# !IMPORTANT! Set your RewriteBase here and don't forget trailing and leading
# slashes.
# If your page resides at
# http://www.example.com/mypage/test1
# then use
# RewriteBase /mypage/test1/
RewriteBase /ci/
#RewriteRule ^index.php/(.*)$ /$1 [R=302,L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
#RewriteCond $1 !^(index\.php|images|robots\.txt|$)
RewriteCond $1 !^(static|$)
#RewriteRule ^(.*)$ index.php?/$1 [L]
RewriteRule ^(.*)$ index.php/$1 [L,QSA]
</IfModule>
<IfModule !mod_rewrite.c>
# If we don't have mod_rewrite installed, all 404's
# can be sent to index.php, and everything works as normal.
# Submitted by: ElliotHaughin
ErrorDocument 404 /index.php
</IfModule>
- /etc/apache2/apache2.conf
<Directory /var/www/ci>
Options Indexes FollowSymLinks
AllowOverride All
#Require all granted
</Directory>
沒有留言:
張貼留言