我已在子网站www.siteb.com/rexona
中安装了CI我的.htaccess www.siteb.com/rexona:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /rexona
#Removes access to the system folder by users.
#Additionally this will allow you to create a System.php controller,
#previously this would not have been possible.
#‘system’ can be replaced if you have renamed your system folder.
RewriteCond %{REQUEST_URI} ^system.*
RewriteRule ^(.*)$ /index.php/$1 [L]
#Checks to see if the user is attempting to access a valid file,
#such as an image or css document, if this isn’t true it sends the
#request to index.php
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
#This last condition enables access to the images and css folders, and the robots.txt file
#Submitted by Michael Radlmaier (mradlmaier)
RewriteCond $1 !^(index\.php|images|robots\.txt|css)
RewriteRule ^(.*)$ index.php/$1 [L]
</IfModule>
<IfModule !mod_rewrite.c>
ErrorDocument 404 /index.php
</IfModule>
在config.php中:
$config['index_page'] = '';
$config['base_url'] = '';
$config['uri_protocol'] = 'AUTO';
每当我尝试访问控制器时,我都会未指定输入文件。但它确实加载了默认控制器,但我无法访问默认控制器中的任何方法。
有什么想法? 感谢。
答案 0 :(得分:25)
您的uri_protocol
需要设置为某种内容 - 至少将其设置为自动。
您得到的错误是因为PHP以CGI身份运行,这意味着您需要将URL重写传递给index.php?/$1
(请注意问号)。
答案 1 :(得分:4)
Godaddy主持,似乎已经固定on.htaccess
,我自己通过改变工作:
RewriteRule ^(.*)$ index.php/$1 [L]
到
RewriteRule ^(.*)$ index.php?/$1 [QSA,L]
答案 2 :(得分:1)
您的$config['uri_protocol']
不应为空。默认值为AUTO
,传入一个空字符串将破坏核心URI类,该类用于通过Router类路由您的请求。
/*
|--------------------------------------------------------------------------
| URI PROTOCOL
|--------------------------------------------------------------------------
|
| This item determines which server global should be used to retrieve the
| URI string. The default setting of 'AUTO' works for most servers.
| If your links do not seem to work, try one of the other delicious flavors:
|
| 'AUTO' Default - auto detects
| 'PATH_INFO' Uses the PATH_INFO
| 'QUERY_STRING' Uses the QUERY_STRING
| 'REQUEST_URI' Uses the REQUEST_URI
| 'ORIG_PATH_INFO' Uses the ORIG_PATH_INFO
|
*/
$config['uri_protocol'] = 'AUTO';
正如评论所说:“如果您的链接似乎无法正常工作,请尝试其他美味口味”。
空字符串不是其中之一,它会结束试图从$_SERVER['']
读取,这通常是空的。
答案 3 :(得分:0)
我在hostinger免费帐户中遇到同样的错误,请解决jhon foo上面提出的问题。
我的.htaccess
RewriteBase /MY_SUBFOLDER_UNDER_HTML_DIRECTORY/
RewriteEngine on
RewriteBase /mY_subfolder/
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/$0 [QSA,L]
这项工作很好,非常感谢!