php:摆脱url中的index.php

时间:2016-11-15 02:55:59

标签: php apache .htaccess codeigniter

有人可以帮我删除我的网址中的默认'index.php'。我已经在互联网上尝试了所有可能的解决方案(我猜...),如何删除这个。自从我开始解决这个问题以来已经过了2天。

的config.php

$host = gethostbyname($_SERVER['SERVER_NAME']);
$config['base_url'] = 'http://'.$host.':8080/rms/';
$config['index_page'] = ''; //-------------------->>>>>this should be blank, right?
$config['uri_protocol'] = 'REQUEST_URI';

我还在codeigniter文件夹中创建了一个.htaccess,其中包含应用程序,图像等。

的.htaccess

RewriteEngine On
    RewriteBase /CodeIgniter/
    RewriteCond %{REQUEST_URI} ^system.*
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.*)$ index.php/$1 [L]

然后我在apache模块中启用rewrite_module并重启所有服务几次仍无法正常工作。(男人们!): - (

我确实在AllowOverride None

中将AllowOverride All更改为httpd.conf

修改 我真的没有得到似乎是什么问题,因为我的网站的第一个界面的第一次加载是好的,但当使用另一个控制器controller/file.php时,错误弹出说;

未找到

在此服务器上找不到请求的URL / rms / eITRMS / btnLoginOnClick / myuser / mypass。

1 个答案:

答案 0 :(得分:0)

我通过删除旧问题并在根目录中创建新的.htaccess来解决问题;

DirectoryIndex index.php
RewriteEngine on
RewriteCond $1 !^(index\.php|images|css|js|robots\.txt|favicon\.ico)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ ./index.php/$1 [L,QSA]

感谢您的回复! ^ _ ^

相关问题