【问题标题】:php: Getting rid of index.php in urlphp:摆脱 url 中的 index.php
【发布时间】:2016-11-15 02:55:59
【问题描述】:

请有人帮我在我的网址中删除这个默认的“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 并重新启动所有服务几次仍然无法正常工作。(哦,伙计!):-(

我确实将httpd.conf 中的AllowOverride None 更改为AllowOverride All

编辑: 我真的不明白似乎是什么问题,因为我网站的第一个界面的第一次加载很好,但是当要使用另一个控制器 controller/file.php 时,会弹出错误提示;

找不到

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

【问题讨论】:

标签: php apache .htaccess codeigniter


【解决方案1】:

我通过删除旧的并在根目录中创建新的.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]

感谢您的回复! ^_^

【讨论】:

    猜你喜欢
    • 2014-07-20
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-10-02
    • 1970-01-01
    相关资源
    最近更新 更多