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 有赏,i卡绘世画不出
  • ¥15 如何用stata画出文献中常见的安慰剂检验图
  • ¥15 c语言链表结构体数据插入
  • ¥40 使用MATLAB解答线性代数问题
  • ¥15 COCOS的问题COCOS的问题
  • ¥15 FPGA-SRIO初始化失败
  • ¥15 MapReduce实现倒排索引失败
  • ¥15 ZABBIX6.0L连接数据库报错,如何解决?(操作系统-centos)
  • ¥15 找一位技术过硬的游戏pj程序员
  • ¥15 matlab生成电测深三层曲线模型代码