codeigniter application works on hostgator but not

2019-09-17 10:30发布

I have a codeigniter application that is working perfectly on my hostgator hosted domain.

I have configured .htaccess and config.php to remove the index.php from the URL. As mentioned this is working 100%. I now need to move the application from my hostgator server to a local server in South Africa with Afrihost.

the modified htaccess and config file are shown below:

my htaccess file is:

RewriteEngine on
RewriteBase /

# Prevent CI index.php
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule .* index.php/$0 [PT,L] 

# Prevent user access to the CI system folder.
RewriteCond %{REQUEST_URI} ^system.*
RewriteRule ^(.*)$ /index.php?/$1 [L] 

# Prevent user access to the CI application folder
RewriteCond %{REQUEST_URI} ^application.*
RewriteRule ^(.*)$ /index.php?/$1 [L]

and my config.php file is:

$config['base_url'] = 'http://logicoportal.co.za';
$config['index_page'] = '';
// let me know if you need to see any other setting

When I try to browse to the domain http://www.logicoportal.co.za I get error This page can't be displayed.

If I browse to my ion auth controller, http://logicoportal.co.za/auth/login I get 404 error The webpage cannot be found.

If I browse to my full codeigniter default path, http://logicoportal.co.za/index.php/auth/login I get error This page can't be displayed

I am assuming it is an htaccess configuration error however I am not sure how to correct this. read many an article with no luck. Alternatively is there another config setting in codeigniter to support this?

I have spoken to the new hosting company, Afrihost and they say they cannot help in this regard.

Any advice / direction would be appreciated.

Thanks as always.

2条回答
可以哭但决不认输i
2楼-- · 2019-09-17 11:16

Working Solution: htaccess file to remove index.php on shared hosting server

DirectoryIndex index.php
RewriteEngine on

RewriteCond %{REQUEST_URI} !^(index\.php|\.swf|forums|images|css|downloads|js|robots\.txt|favicon\.ico)$
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*) ./index.php [L]
查看更多
forever°为你锁心
3楼-- · 2019-09-17 11:16

Try removing the ? in:

RewriteRule ^(.*)$ /index.php?/$1

So it's:

RewriteRule ^(.*)$ /index.php/$1
查看更多
登录 后发表回答