我似乎无法在GoDaddy上正确设置CodeIgniter。我尝试在'wecome'控制器中创建一个新函数。但我无法在任何地方访问它。
http://domain.com/test (No response) <- why doesn't this work
http://domain.com/index.php/welcome/test (No response) <- why doesn't this work
只是为了让您了解默认欢迎页面如何解决:
http://domain.com/ (resolves to welcome page aka 'index' function)
http://domain.com/index.php/ (resolves to welcome page aka 'index' function)
http://domain.com/index.php/welcome (No response) <- why doesn't this work?
http://domain.com/index.php/welcome/index (No response) <-why doesn't this work?
如何正确设置?
答案 0 :(得分:5)
步骤1.在根目录下的.htaccess文件中设置:
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_URI} ^system.*
RewriteRule ^(.*)$ /index.php?/$1 [L]
RewriteCond %{REQUEST_URI} ^application.*
RewriteRule ^(.*)$ /index.php?/$1 [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/$1 [L]
RewriteCond %{HTTP_HOST} ^mydomain.com [NC]
RewriteRule ^(.*)$ http://www.mydomain.com/$1 [L,R=301]
步骤2.打开/system/application/config/config.php文件,确保设置了以下两个选项。
$config['index_page'] = “”;
$config['uri_protocol'] = “AUTO“;
希望这会有所帮助。
答案 1 :(得分:1)
你可以找到这个问题的可能的地方是.htaccess文件(从未使用过godaddy,但我见过其他人对这个托管公司有不同的.htaccess规则),接下来是你的application / config / config.php文件和uri_protocol,试验这个(你可以通过几个值),也可以根据你的CI版本扩展CI_URI或CI_Router类,以便在某处插入你的逻辑,但正如我所说,这将取决于在您使用的CI版本上,从1.7到2.0.2,他们对这些负责路由和uri匹配的类进行了一些更改,如果您找不到解决方案,请返回并发布更多信息。
答案 2 :(得分:0)
尝试这一行:
@ini_set('cgi.fix_pathinfo', 0);
在/index.php文件中。还可以在config.php中使用URI_PROTOCOL设置。
答案 3 :(得分:0)
要执行此操作,请打开application / config / config.php文件并更改:
$config['index_page'] = "index.php";
对此:
$config['index_page'] = "index.php?";