【问题标题】:codeigniter removing index.php from url in wampcodeigniter 从 wamp 中的 url 中删除 index.php
【发布时间】:2014-08-19 10:15:28
【问题描述】:

我在尝试从 url 中删除 index.php 时遇到很大问题

我已经搜索了很多论坛(这也是),但对我的情况没有帮助。

所以我有 config.php 文件

$config['base_url'] = '';
$config['index_page'] = '';
$config['uri_protocol'] = 'AUTO';

我的 .htaccess 文件在 index.php 附近的 public_html 文件夹中

<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /public_html/

    RewriteCond %{REQUEST_URI} ^system.*
    RewriteRule ^(.*)$ /index.php?/$1 [L]

    RewriteCond %{REQUEST_URI} ^application.*
    RewriteRule ^(.*)$ /index.php?/$1 [L]

    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.*)$ index.php?/$1 [L]
</IfModule>

<IfModule !mod_rewrite.c>
    ErrorDocument 404 /index.php
</IfModule> 

在 WAMP apache(版本:2.4.9)中,我打开了 rewrite_module(并且它正在工作) 并且我的 httpd.conf AllowOverride 设置为 All

所以当我要去 mydomain.com/controller/action - 我得到 404 但是当我访问 mydomain.com/index.php/controller/action 时 - 一切正常..

我已经尝试了很多 .htaccess 示例......等等......没有任何帮助......

【问题讨论】:

    标签: php apache .htaccess codeigniter url


    【解决方案1】:

    使用这个 htacess 然后去 config.php 并删除 index.php

    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]
    

    【讨论】:

    • 仍然没有.. 得到“在此服务器上找不到请求的 URL WayTillMyProject/public_html/index.php/admin/dashboard/modal。”
    • 我看到您的基本网址中没有任何内容,请尝试在其中添加您的网址。并添加 url helper 确保路由设置正确。 $route['perferdname'] = folder/controller/index$route['perferdname'] = controller/index
    • 现在重定向到 CI errors/index.php 以获取 404 错误
    • Whats 检查您的路线,如下所示,每个控制器都需要路线
    • 真的不知道你想说什么/检查你是否在谈论routes.php文件,我没有改变任何东西..
    猜你喜欢
    • 2015-10-27
    • 2011-10-28
    • 1970-01-01
    • 2016-05-14
    • 2014-10-28
    • 2012-06-15
    • 2012-09-21
    相关资源
    最近更新 更多