Jer*_*lle 5 php .htaccess codeigniter
我想删除URL中的index.php,但它不起作用.这是我做的:
我编辑了codeigniter文件夹中的.htaccess.我根据文档中的示例添加了这个.
RewriteEngine On
RewriteCond%{REQUEST_FILENAME}! - f
RewriteCond%{REQUEST_FILENAME}!-d
RewriteRule ^(.*)$ index.php/$ 1 [L]
然后我也删除了app/config中的index.php
然后我创建一个简单的控制器:
class Users extends CI_Controller {
public function __construct() {
parent::__construct();
}
public function index() {
echo "hello world";
}
}
Run Code Online (Sandbox Code Playgroud)当我访问此网址时:
http://localhost/order_menu/users
Run Code Online (Sandbox Code Playgroud)
我收到了这个错误:
Not Found
The requested URL /order_menu/users was not found on this server.
Run Code Online (Sandbox Code Playgroud)
你能帮帮我吗?
使用wamp时确保已启用Apache Modules"rewrite_module"重启服务器
第二
在项目的主目录中尝试这个htaccess
Options +FollowSymLinks
Options -Indexes
DirectoryIndex index.php
RewriteEngine on
RewriteCond $1 !^(index\.php|images|robots\.txt)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L,QSA]
Run Code Online (Sandbox Code Playgroud)
然后转到application/config/config.php
找
$config['index_page'] = 'index.php';
然后使index.php为空
用...来代替
$config['index_page'] = '';
您可能需要配置路由
CI3:http://www.codeigniter.com/user_guide/general/routing.html
CI2:http://www.codeigniter.com/userguide2/general/routing.html
| 归档时间: |
|
| 查看次数: |
1903 次 |
| 最近记录: |