dongliang_bj2016 2012-10-01 23:39
浏览 45
已采纳

Codeigniter在xampp上处理虚拟主机时删除index.php

My previous folder tree was (with portable xampp): (for example working on D: drive root)

/xampp/htdocs/application
/xampp/htdocs/system
/xampp/htdocs/themes
/xampp/htdocs/index.php etc..

Now I am trying to shift into a structure which I can work with multiple projects so new tree:

/xampp/htdocs
/web_projects/project-name/codeigniter/application
/web_projects/project-name/codeigniter/system
/web_projects/project-name/htdocs/themes
/web_projects/project-name/htdocs/index.php

My htaccess file in htdocs:

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond $1 !^(index\.php|robots\.txt)

# if Serves works on Linux OS
RewriteRule ^(.*)$ index.php/$1

# if Server works on Windows OS
# RewriteRule ^(.*)$ index.php?/$1

RewriteCond %{REQUEST_FILENAME} !-f

# if Serves works on Linux OS
RewriteRule ^(application|modules|plugins|system|themes|library|files) index.php/$1 [L]

# if Server works on Windows OS
# RewriteRule ^(application|modules|plugins|system|themes|library|files) index.php?/$1 [L]

And httpd-vhosts.conf:

NameVirtualHost *:8080

<VirtualHost *:8080>
    DocumentRoot "/xampp/htdocs"
    ServerName localhost
    <Directory "/xampp/htdocs">
        Order allow,deny
        Allow from all
    </Directory>
</VirtualHost>

<VirtualHost *:8080>
    DocumentRoot "/web_projects"
    ServerName welcome.localhost
    <Directory "/web_projects">
        Order allow,deny
        Allow from all
    </Directory>
</VirtualHost>

<VirtualHost *:8080>
    DocumentRoot "/web_projects/test/htdocs"
    ServerName test.localhost
    <Directory "/web_projects/test/htdocs">
        Order allow,deny
        Allow from all
    </Directory>
</VirtualHost>

Finally etc/host:

127.0.0.1 localhost
127.0.0.1 welcome.localhost
127.0.0.1 test.localhost
127.0.0.1 vstart # Alias for test

All virtual hosts are working, i.e. http://vstart:8080/ is working but codeigniter not operates without index.php in address line, so routes are not working in accordance.

My config/config.php file is:

$config['base_url'] = ((isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == "on") ? "https" : "http");
$config['base_url'] .= "://".$_SERVER['HTTP_HOST'];
$config['base_url'] .= str_replace(basename($_SERVER['SCRIPT_NAME']),"",$_SERVER['SCRIPT_NAME']);

$config['index_page'] = '';

This set was working smoothly in my previous folder tree now is not working. I digged internet to find a solution with failure.

Any outer eyes to catch where I am doing wrong?

  • 写回答

2条回答 默认 最新

  • douyan4470 2012-10-02 08:36
    关注

    Found the solution:

    All I need to do is add "AllowOverride All" to respected vhost.

    Hope helps someone in the future.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 PointNet++的onnx模型只能使用一次
  • ¥20 西南科技大学数字信号处理
  • ¥15 有两个非常“自以为是”烦人的问题急期待大家解决!
  • ¥30 STM32 INMP441无法读取数据
  • ¥15 R语言绘制密度图,一个密度曲线内fill不同颜色如何实现
  • ¥100 求汇川机器人IRCB300控制器和示教器同版本升级固件文件升级包
  • ¥15 用visualstudio2022创建vue项目后无法启动
  • ¥15 x趋于0时tanx-sinx极限可以拆开算吗
  • ¥500 把面具戴到人脸上,请大家贡献智慧,别用大模型回答,大模型的答案没啥用
  • ¥15 任意一个散点图自己下载其js脚本文件并做成独立的案例页面,不要作在线的,要离线状态。