[英]CodeIgniter doesn't work on Server
我尝试了所有解决方案的变体,但仍然无法正常工作。
我在本地主机(MAMP)中开发了一些脚本
然后,我复制了文件和文件夹,但codeIgniter表示The page you requested was not found.
我怎么解决这个问题 ?
我试过了:-.htaccess修改:
RewriteEngine On
RewriteBase /review/
RewriteCond %{REQUEST_URI} ^system.*
RewriteCond $1 !^(index\.php|images|js|uploads|css|robots\.txt)
RewriteRule ^(.*)$ /index.php/$1 [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]
配置修改:
$config['base_url'] = 'http://oursite.com/review/';
$config['uri_protocol'] = 'REQUEST_URI';
仍然不起作用。
请帮助我。
亲切的问候。
尝试使用代码而不是输入来获取baseurl:在config中添加以下行。
$root = "http://".$_SERVER['HTTP_HOST'];
$root .= str_replace(basename($_SERVER['SCRIPT_NAME']),"",$_SERVER['SCRIPT_NAME']);
$config['base_url'] = "$root";
并且如果您的链接似乎不起作用,请尝试以下其他方法之一:
$config['uri_protocol'] = 'AUTO'; // This works for most servers.
“自动”默认-自动检测
'PATH_INFO'使用PATH_INFO
“ QUERY_STRING”使用QUERY_STRING
'REQUEST_URI'使用REQUEST_URI
'ORIG_PATH_INFO'使用ORIG_PATH_INFO
您的设置是正确的,但是在您的.htaccess文件中,请用以下内容替换所有内容:
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule .* index.php/$0 [PT,L]
然后在其后编写您自己的规则。
编辑
另外,我在项目中使用了大量CI,然后我的配置文件将通过以下步骤:
config.php文件
$config['base_url'] = ''; $config['index_page'] = '';
routes.php文件
$route['default_controller'] = "main";
具有以上.htaccess
设置的所有服务器和本地计算机都可以使用。
并注意使您的CI在另一个目录/子域中工作,然后再次检查它。
.htaccess取决于服务器。 希望它将对您有所帮助:
RewriteEngine on
RewriteCond $1 !^(index\.php|resources|robots\.txt)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/$1 [L,QSA]
您还可以按照以下讨论:
和
您可以尝试以下方法:
<IfModule mod_rewrite.c> RewriteEngine on RewriteBase /review/ RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^(.*)$ index.php/$1 [L] </IfModule>
: <IfModule mod_rewrite.c> RewriteEngine on RewriteBase /review/ RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^(.*)$ index.php/$1 [L] </IfModule>
config: $config['base_url'] = 'http://www.oursite.com/review/';
: $config['base_url'] = 'http://www.oursite.com/review/';
路线: $route['default_controller'] = "realm";
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.