删除index.php - 控制器方法不起作用

时间:2013-08-13 16:33:10

标签: codeigniter

我在主目录中有codeigniter应用程序。在/ var / www / html中创建的Sym链接。我对应用程序文件夹中的inchue .htaccess文件进行了更改,以删除URL中的index.php。以下链接正常。

http://mydomain.net/dms/welcome

也就是说,控制器的默认方法工作正常。但是当我在欢迎控制器中有方法'test'时,以下链接导致找不到HTTP 404网页错误。

http://mydomain.net/dms/welcome/test

代码点火器2.1.1目录:

dms
    application
    system
    index.php
    .htaccess

的config.php

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

配置文件httpd.conf

Alias /dms/ "/var/www/html/dms/"
<Directory "/var/www/html/dms">
    Options Indexes MultiViews FollowSymLinks
    AllowOverride All
    Order allow,deny
    Allow from all
</Directory>

Sym链接

ls -l /var/www/html
dms -> /home/user1/dms

.htaccess文件

    Options +FollowSymLinks -Indexes
    Options -MultiViews
    RewriteEngine on

    <IfModule mod_php5.c>
        RewriteRule ^([^/]*)$ index.php/$1 [L]
    </IfModule>

    <IfModule !mod_php5.c>
        RewriteRule ^([^/]*)$ index.php?/$1 [L]
    </IfModule>

我还尝试使用以下2个重写规则代替.htaccess文件中的上述规则。

RewriteRule ^(.*)$ index.php/$1 [L]
RewriteRule ^(.*)$ index.php?/$1 [L]

但是不使用URL中的index.php就可以访问控制器方法。花了很多时间在这上面,我认为这与Rewrite规则有关。有人可以指导我这个。

1 个答案:

答案 0 :(得分:0)

请测试.htaccess

的此配置
RewriteEngine on
RewriteCond $1 !^(index\.php|.*\.css|.*\.js)
RewriteRule ^(.*)$ /angular1/index.php/$1 [L]

用正确的路径替换“angular1”。