1

我有一个使用 XAMPP 在 Windows 中工作的 codeigniter proyect,现在我将它移动到我的 RaspberryPi:

  1. Apache/2.2.22 (Debian)
  2. PHP 5.4.4-14+deb7u5
  3. mysql Ver 14.14 发行版 5.5.31

我有两个使用这种结构的 codeignitir 应用程序(主要和面板)

/ -> (apache root folder)
/appname/admin 
        /admin/application/ -> (codeigniter application to panel)
/appname/application/ -> (codeigniter application to public)

现在我无法访问管理控制器,我认为是因为 .htaccess。我在一些 url 中得到了这个:my.domain/appname -> codeigniter welcome for public(这部分是空的,所以我认为没问题) my.domain/appname/admin/login.html -> Not Found。在此服务器上找不到请求的 URL /mydomain/admin/login。my.domain/appname/admin/index.php?controller=admin -> 404 Page Not Found (codeigniter style) my.domain/appname/admin/hello.html -> hello (我尝试的一个虚拟文件,工作正常)

在我的 codeigniter 面板项目中,我有

$config['base_url'] = 'http://my.domain/myapp/admin/';
$config['index_page'] = '';
$config['uri_protocol'] = 'AUTO';
$config['url_suffix'] = '.html';

我认为这都是关于 .htaccess 的,但我不理解它们。我需要多少文件?什么文件夹?

我之前在 /appname 和 /appname/panel 中有这个 .htaccess

<IfModule mod_rewrite.c>
RewriteEngine on
RewriteBase /appname #to panel /appname/panel

#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 ^(.*)$ /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
#This last condition enables access to the images and css folders, and the robots.txt file
RewriteCond $1 !^(index\.php|images|robots\.txt|css)
RewriteRule .* index.php/$0 [PT,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>

我认为 RewriteEngine on 在我的 apache2 中被激活。

4

2 回答 2

0

我在管理员文件夹中找到了 .htaccess 的解决方案:

<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /appname/admin

    #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 ^(.*)$ /index.php?/$1 [L]

    #When your application folder isn't in the system folder
    #This snippet prevents user access to the application folder
    #Submitted by: Fabdrol
    #Rename 'appname' to your applications folder name.
    RewriteCond %{REQUEST_URI} ^appname.*
    RewriteRule ^(.*)$ /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 ^(.*)$ 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>

CodeIgniter 多个应用程序 htaccess

于 2013-11-09T15:47:56.987 回答
0
<IfModule authz_core_module>
RewriteEngine on
RewriteRule ^([a-z0-9_-]+)\.html$ index.php/page/$1 [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond $1 !^(index\.php|asset|robots\.txt)
RewriteRule ^(.*)$ index.php/$1 [L]
</IfModule>
于 2018-11-28T16:51:02.233 回答