我有一个使用 XAMPP 在 Windows 中工作的 codeigniter proyect,现在我将它移动到我的 RaspberryPi:
- Apache/2.2.22 (Debian)
- PHP 5.4.4-14+deb7u5
- 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 中被激活。