【问题标题】:Problems with codeigniter on ubuntuubuntu 上的 codeigniter 问题
【发布时间】:2011-02-22 19:15:38
【问题描述】:

我在 Ubuntu 10 (LAMP) 上安装了 Codeigniter。我有一个 htaccess 文件:

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /dort
#Removes access to the system folder by users.
#Additionally this will allow you to create a System.php
#controller, previously this would not have been possible.
#'system' can be replaced if you have renamed your system folder.
RewriteCond %{REQUEST_URI} ^system.*
RewriteRule ^(.*)$ /dort/index.php?/$1 [L]
#Checks to see if the user is attempting to access a valid file,
#such as an image or css document, if this isn't true it sends
#the request to index.php
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /dort/index.php?/$1 [L]
</IfModule>
<IfModule !mod_rewrite.c>
# If we don't have mod_rewrite installed, all 404's
# can be sent to index.php, and everything works as normal.
# Submitted by: ElliotHaughin
ErrorDocument 404 /index.php
</IfModule>

到目前为止,我们使用 IP 地址连接了远程服务器,我的基地位于一个名为 ‘dort’,所以我们习惯这样称呼它:http://some_ip/dort

现在我们将虚拟主机映射到 dort,所以我们称它为:http://demo.dort.com/,然后突然什么都没有了

除了登录页面 (index.php) 之外的工作。我在 config.php 中更改了 $config['base_url'] 但我

继续获取 404。

请帮忙:(

【问题讨论】:

    标签: php apache .htaccess codeigniter ubuntu


    【解决方案1】:

    你用过虚拟主机吗?

    我有同样的问题并用这个解决

    1) 在我的情况下创建虚拟主机是这样的:文件 /etc/apache2/sites-available/default

    <VirtualHost *:80>
        ServerAdmin admin@email.com
        DocumentRoot /var/www/dort
        ServerName yourdomain.biz #this domain must be define tld info.
        ErrorLog /var/log/apache2/error_2.log
        <Directory /var/www/dort>
            Options Indexes FollowSymLinks MultiViews
                    AllowOverride All
                    Order allow,deny
                    allow from all
                    # Uncomment this directive is you want to see apache2's
                    # default start page (in /apache2-default) when you go to /
                    #RedirectMatch ^/$ /apache2-default/
    
        </Directory>
    
    </VirtualHost>
    

    2) 在文件 /etc/hosts 中设置主机

    127.0.0.1   localhost
    127.0.0.1   yourdomain.biz
    # The following lines are desirable for IPv6 capable hosts
    ::1     localhost ip6-localhost ip6-loopback
    fe00::0 ip6-localnet
    ff00::0 ip6-mcastprefix
    ff02::1 ip6-allnodes
    ff02::2 ip6-allrouters
    ff02::3 ip6-allhosts
    

    3).htaccess

    <IfModule mod_rewrite.c>
        RewriteEngine On
        RewriteBase /
    
        # Send admin URL's to the admin controller (then skips the rest of the redirect rules)
        RewriteCond %{REQUEST_URI} ^/admin(.*)
        RewriteRule ^(.*)$ /index.php/admin/$1 [L]    
    
        # Redirects any request thats not a file or directory through to the main controller
        RewriteCond %{REQUEST_FILENAME} !-f
        RewriteCond %{REQUEST_FILENAME} !-d
        RewriteRule ^(.*)$ /index.php/main/$1 [L]
    
    </IfModule>
    
    <IfModule !mod_rewrite.c>
        # If we don't have mod_rewrite installed, all 404's
        # can be sent to index.php, and everything works as normal.
    
        ErrorDocument 404 /index.php
    </IfModule> 
    

    4) 确保重启 apache 时不显示错误

     Could not reliably determine the server's fully qualified domain name, using 127.0.0.1 for ServerName
    

    5) 去浏览运行这个urlhttp://yourdomain.biz

    【讨论】:

      【解决方案2】:

      以上解决方案对我有用。我只想强调一件事。确保您在 /etc/apache2/sites-available/default 的虚拟主机文件中具有 AllowOverride All 而不是 AllowOverride None

      【讨论】:

        猜你喜欢
        • 2016-08-25
        • 2018-09-02
        • 1970-01-01
        • 1970-01-01
        • 2013-04-20
        • 2013-07-07
        • 2020-12-10
        • 2016-11-08
        • 2020-10-17
        相关资源
        最近更新 更多