几天来我一直在尝试解决这个问题,并尝试了以下教程:
还有许多其他人。
没有一个工作。
这是我的问题:
每当我单击 WAMP localhost/ci/index.php/HomeController 中的站点链接时,它都可以正常工作。
但是,如果我从 url (localhost/ci/HomeController) 中省略“index.php”,它会显示与 localhost 相同的文件夹列表。
这是我在根目录下的 htaccess 文件:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /ci/
#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>
在配置文件中:
$config['base_url'] = 'http://localhost/ci/';
$config['index_page'] = '';
$config['uri_protocol'] = 'AUTO';
这仍然将我重定向到 WAMP 主页。
我也取消了注释(在 httpd.conf 文件中)。
LoadModule rewrite_module modules/mod_rewrite.so
附加信息:
在我的 routes.php 文件中:
$route['default_controller'] = "HomeController";
我的缩写文件结构:(位于 C:\wamp\www)
- /ci
- /应用
- /缓存
- /配置
- /控制器
- /核
- /错误
- /帮手
- /钩子
- /语言
- /图书馆
- /日志
- /楷模
- /第三者
- /意见
- .htaccess
- 索引.html
- /资产
- /系统
- .htaccess
- 索引.php
- /应用
任何帮助表示赞赏。抱歉,如果已经有关于此主题的答案。没有人为我的项目工作。
编辑:
如果我尝试这个 htaccess:
RewriteEngine on
RewriteCond $1 !^(index\.php|images|robots\.txt)
RewriteRule ^(.*)$ /ci/index.php?/$1 [L]
我得到:
Internal Server Error
The server encountered an internal error or misconfiguration and was unable to complete your request.
Please contact the server administrator, admin@localhost 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.