dsxml2169 2016-10-31 14:23 采纳率: 0%
浏览 28
已采纳

CodeIgniter部署与网址奇怪的问题

I've just finished my CI's project and I've uploaded it through FTP to an external server. The thing is that the urls stuff works perfectly on localhost but not in the external server, altough the urls work if I put index.php on the URI.

Example: www.page.com/index.php/shop (works), www.page.com/shop (doesn't work)

I've made my research and all the answers I've found doesn't seem to fit well on my case. I'm working on Linux that use Apache2. I've made these changes:

1-/var/www/dev.example.com (Apache2):

<VirtualHost *:80>
<Directory /var/www/dev.example.com>
Options FollowSymLinks
AllowOverride All
</Directory>

2-Config.php(CI):

$config['base_url'] = 'http://' . $_SERVER['HTTP_HOST'] . '/dev.example.com';

3-htaccess(CI):

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /index.php?/$1 [L]

4-index.php(CI):

define('ENVIRONMENT', 'production')

What am I missing? Excuse me for my bad english.

EDIT:

I think the problem is that the .htaccess file it's not been called for some reason, so for many changes I make to the file the result will be the same. How can I see if the file it's being used?

  • 写回答

4条回答 默认 最新

  • dongyongyin5339 2016-11-02 11:00
    关注

    Finally I found the solucion. A file named 000-default under /etc/apache2/sites-enabled was causing the troubles. I had something like:

    <Directory /var/www/ > 
    Options Indexes FollowSymLinks MultiViews
    AllowOverride None
    ...
    </Directory>
    

    So I just changed it to:

    <Directory /var/www/ > 
    Options Indexes FollowSymLinks MultiViews
    AllowOverride All
    ...
    </Directory>
    

    And that after a sudo apache2 restart fix my problem. So basically this file was overriding my VHost file.

    Hope it helps someone!

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

报告相同问题?

悬赏问题

  • ¥15 虚幻5 UE美术毛发渲染
  • ¥15 CVRP 图论 物流运输优化
  • ¥15 Tableau online 嵌入ppt失败
  • ¥100 支付宝网页转账系统不识别账号
  • ¥15 基于单片机的靶位控制系统
  • ¥15 真我手机蓝牙传输进度消息被关闭了,怎么打开?(关键词-消息通知)
  • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
  • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
  • ¥15 手机接入宽带网线,如何释放宽带全部速度
  • ¥30 关于#r语言#的问题:如何对R语言中mfgarch包中构建的garch-midas模型进行样本内长期波动率预测和样本外长期波动率预测