我已经把头发拔了三天了,我用谷歌搜索了所有东西,上过代码点火器论坛,并从上到下检查了堆栈溢出。
我想要做的就是从 url 中删除 index.php。我发现的最接近我的问题的帖子没有得到回答: 帖子
如果我去localhost/CodeIgniter
我的主页显示。如果我单击我的链接,我会收到该页面不存在的错误。
404 Page Not Found
The page you requested was not found.
根据我读过的所有内容,这是我当前的配置。
MAC OSX 10.8.3 MAMP CodeIgniter 2.1.3
我的根目录是 www/CodeIgniter/ 这是 CodeIgniter Root 中的 .htaccess 文件
#Deny from all
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /CodeIgniter/
#Removes access to the system folder by users.
#Additionally this will allow you to create a System.php controller,
#previously this would not have been possible.
#'system' can be replaced if you have renamed your system folder.
RewriteCond %{REQUEST_URI} ^system.*
RewriteRule ^(.*)$ /index.php?/$1 [L]
#When your application folder isn't in the system folder
#This snippet prevents user access to the application folder
#Submitted by: Fabdrol
#Rename 'application' to your applications folder name.
RewriteCond %{REQUEST_URI} ^application.*
RewriteRule ^(.*)$ /index.php?/$1 [L]
#Checks to see if the user is attempting to access a valid file,
#such as an image or css document, if this isn't true it sends the
#request to index.php
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/$1 [L]
</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>
这是 CodeIgniter 的配置设置:我尝试了 uri_protocol 的所有设置,但没有成功
$config['index_page'] = '';
$config['uri_protocol'] = 'AUTO';
我确认我已启用 mod_rewrite,并且 httpd.conf 中的 AllowOverride 设置为 All。
****更新所以我删除了 MAMP 和 codeigniter 并从头开始。现在使用下面的 .htaccess 文件,当我转到 localhost 时,不会显示 codeigniter 文件夹。如果我尝试浏览到该文件夹,我会收到以下错误。
Internal Server Error
The server encountered an internal error or misconfiguration and was unable to complete your request.
Please contact the server administrator, you@example.com and inform them of the time the error occurred, and anything you might have done that may have caused the error.
More information about this error may be available in the server error log.
当我查看错误日志时,出现以下错误。
[Mon Apr 22 21:42:51 2013] [alert] [client ::1] /Users/me/Dropbox/www/codeigniter/.htaccess: <IfModule takes one argument, Container for directives based on existance of specified modules
我确认我在 phpinfo(); 中启用了 mod_rewrite;
如果我删除 .htaccess 文件,我可以浏览到该文件夹并获取主页,但当然链接不起作用。任何建议将不胜感激。
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /codeigniter/
#Removes access to the system folder by users.
#Additionally this will allow you to create a System.php controller,
#previously this would not have been possible.
#'system' can be replaced if you have renamed your system folder.
RewriteCond %{REQUEST_URI} ^system.*
RewriteRule ^(.*)$ /index.php?/$1 [L]
#When your application folder isn't in the system folder
#This snippet prevents user access to the application folder
#Submitted by: Fabdrol
#Rename 'application' to your applications folder name.
RewriteCond %{REQUEST_URI} ^application.*
RewriteRule ^(.*)$ /index.php?/$1 [L]
#Checks to see if the user is attempting to access a valid file,
#such as an image or css document, if this isn't true it sends the
#request to index.php
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/$1 [L]
</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>