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?

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!

$root = "http://".$_SERVER['HTTP_HOST'];
$root .=  str_replace(basename($_SERVER['SCRIPT_NAME']),"",$_SERVER['SCRIPT_NAME']);

$config['base_url'] = $root;

try changing your base url to this.hope it works

i hope your htacess look something like this

<IfModule mod_rewrite.c>
RewriteEngine on   
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d

RewriteRule ^(.*)$ index.php?/$1 [L]
</IfModule>

And uri_protocol in your config file look like this $config['uri_protocol'] = 'REQUEST_URI';

Well I have this .htaccess running on my CI application in the server. Why not give this a try?

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

After you created/changed your virtual host file (1-/var/www/dev.example.com), did you restarted apache2 so those changes could take effect?

One way to do so (in case you didn't), is running this at your server's terminal:

$ sudo systemctl restart apache2

or

$ sudo service apache2 restart