从CodeIgniter URL中删除index.php [英] Remove index.php from CodeIgniter URLs

查看:85
本文介绍了从CodeIgniter URL中删除index.php的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试访问不带'index.php'的CodeIgniter URL.这是我已采取的步骤:

I'm trying to access CodeIgniter URLs without 'index.php'. Here's the steps I've taken:

  1. 已启用检查的mod_rewrite -我设置了一条规则,将所有请求重定向到google,这是可行的.还检查了"AllowOverride All"是否已设置

  1. Checked mod_rewrite is enabled - I set a rule to redirect all requests to google, which worked. Also checked that 'AllowOverride All' was set

添加了一个.htaccess文件,内容如下:

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

  • 在网络服务器上设置我的目录结构,如下所示:

  • Set my directory structure on the webserver as follows:

    /home/wwwsunde/
    -> application
    -> system
    -> public_html
        -> index.php
        -> .htaccess
    

  • 更新了我的应用程序/配置文件,因此系统和应用程序路径为"../system"和"../application"

  • Updated my application/config files so that the system and application paths are '../system' and '../application'

    尝试从2个URL访问网站

    Try to access the site from 2 URLs

    http://109.234.194.207/~wwwsunde/index.php/welcome/membership WORKS
    http://109.234.194.207/~wwwsunde/welcome/membership DOES NOT WORK
    

  • 我还按照指南将CodeIgniter的索引页变量设置为空白

  • I've also set CodeIgniter's index page variable to blank as per the guide

    显示的错误消息:

    The requested URL /home/wwwsunde/public_html/index.php/welcome/membership was not found on this server.
    

    对于可能出什么问题我没有主意-这是Apache或服务器问题,但我不确定是什么...

    I'm out of ideas as to what could be wrong - it's an Apache or server issue but I'm not sure what...

    推荐答案

    哦...我知道为什么...将此设为您的重写规则:

    Oh... I know why... make this your rewrite rule:

    RewriteRule .* index.php/$0 [PT]
    

    您拥有的[L]只是一个最后规则",但您不想安静地处理后台shell游戏,因此不会执行退出重写.这将是一个无休止的循环.如果这样做不起作用,请在重写中指定完整的URL,例如:

    The [L] you had was just a 'last rule' but wouldn't do the quit rewrite you want to quietly handle the background shell game. It would be an endless loop. If this doesn't work, specify the full URL in the rewrite like:

     RewriteRule .* http://109.234.194.207/~wwwsunde/index.php/$0  [PT]
    

    这篇关于从CodeIgniter URL中删除index.php的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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