删除index.php - 控制器方法不工作 [英] Removing index.php - Controller Methods not working

查看:183
本文介绍了删除index.php - 控制器方法不工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在主目录中有codeigniter应用程式。 Sym链接在/ var / www / html中创建。我做了更改包括应用程序文件夹中的.htaccess文件以删除URL中的index.php。以下链接工作正常。

  http://mydomain.net/dms/welcome 

也就是说,控制器的默认方法很好。但是当我在welcome控制器中有方法'test'时,以下链接导致HTTP 404网页未找到错误。

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

代码igniter 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>
选项索引MultiViews FollowSymLinks
AllowOverride所有
订单允许,拒绝
允许所有
< / Directory>

Sym链接

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

.htaccess文件

  Options + FollowSymLinks -Indexes 
选项-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文件中的上述规则。 p>

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

但是无法在URL中使用index.php访问contoller方法。花了很多时间在这里,我认为这是与重写规则有关。可能有人指导我这个。

解决方案

请为.htaccess测试此配置

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

p>

I have codeigniter app in home directory. Sym link created in /var/www/html. I made changes to incldue .htaccess file in application folder to remove index.php in URL. The below link works fine.

http://mydomain.net/dms/welcome

That is, default method of controller works fine. But when I have method 'test' in welcome controller, the following link results in HTTP 404 webpage not found error.

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

Code igniter 2.1.1 directory:

dms
    application
    system
    index.php
    .htaccess

Config.php

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

Config file 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 links

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

.htaccess file

    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>

I also tried with the following 2 Rewrite rules in place of above rules in .htaccess file.

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

But contoller method cant be accessed without using index.php in URL. Having spent much time in this, I think it is something to do with Rewrite rules. Could some one guide me on this.

解决方案

Please, test this configuration for .htaccess

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

Replace "angular1" by your correct path.

这篇关于删除index.php - 控制器方法不工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆