【发布时间】:2014-01-27 16:27:12
【问题描述】:
我有一个 codeigniter php 应用程序,它在我的本地机器 (IIS) 上运行良好,但是当我将它部署到 LAMP 服务器 (Apache) 上时,我只能访问 http://<ip-ddress>:8080/company/ 但 不能 任何该网站上的其他链接,例如。 http://<ip-ddress>:8080/company/help、http://<ip-ddress>:8080/company/aboutus等
这是我在远程服务器上的 Apache 虚拟主机条目:
<VirtualHost *:8080>
ServerAdmin xxxxxxx@xxx.xxx.xxx
DocumentRoot "/app/content/pages"
DirectoryIndex index.php
ServerName company.xxx.xxxx.xxx
ServerAlias company.xxx.xxxx.xxx
LogLevel debug
ErrorLog "|/app/server/apache2/bin/rotatelogs logs/company.xxx.xxxx.xxx-error_log 50M"
<Directory "/app/content/pages">
Options Includes FollowSymLinks
AllowOverride All Options FileInfo
Order allow,deny
Allow from all
<IfModule mod_php5.c>
AddType application/x-httpd-php .php
php_flag magic_quotes_gpc Off
php_flag track_vars On
php_flag register_globals Off
php_value include_path .
</IFModule>
</Directory>
#
# The following lines prevent .htaccess and .htpasswd files from being
# viewed by Web clients.
#
<FilesMatch "^\.ht">
Order allow,deny
Deny from all
Satisfy All
</FilesMatch>
AddType text/html .shtml
AddOutputFilter INCLUDES .shtml
ServerSignature Off
</VirtualHost>
这是我的 codeigniter 配置设置 - application/config/config.php
$config['base_url'] = 'http://<ip-address>:8080/company/';
$config['index_page'] = 'index.php';
$config['uri_protocol'] = 'AUTO';
$config['url_suffix'] = '';
$config['proxy_ips'] = '';
这是我的application/config/routes.php:
$route['(:num)'] = "home/index/$1";
$route['help'] = "home/help";
$route['home/(:num)'] = "home/index/$1";
$route['default_controller'] = "home";
$route['404_override'] = '';
【问题讨论】:
-
看起来您并没有重写
index.php文件。http://<ip-ddress>:8080/company/index.php/help有效吗? -
@stormdrain 确实有效!!
-
谢谢!
的最佳位置是什么?是否应该将其添加到 httpd-vhosts.conf 虚拟主机条目中? -
通常人们会将
.htaccess放在 Ci 应用程序的根文件夹中,并在那里进行重写。见ellislab.com/codeigniter/user-guide/general/urls.html
标签: php apache codeigniter virtualhost