这是我上传到在线服务器的第一个应用程序。我在CodeIgniter 3.0.1上创建了应用程序并将其上传到000webhost.com。但问题是,我的链接都没有被路由。我在网上查了一下,我的.htacess
文件似乎是正确的。我已经检查了这个问题My .htaccess file is not working,我和他有同样的问题,但是正确答案没有用。
继承我的.htacess
文件
DirectoryIndex index.php
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond $1 !^(index\.php|public|images|css|js|robots\.txt)
RewriteRule ^(.*)$ index.php?/$1 [L]
答案 0 :(得分:1)
您能否确保创建了特定的“控制器”&这是你试图路由的“方法”?我的意思是你能从字面上验证他们的拼写吗?
您还可以尝试创建规则:
$route['club'] = 'welcome/index';
你能看出上述规则是否有效吗?你有没有名为'club.php'的其他控制器?
答案 1 :(得分:1)
我和你有同样的问题。
检查 .htaccess 是否隐藏,如果隐藏尝试显示隐藏文件,瞧
答案 2 :(得分:-1)
试试这个并告诉我们它是否有效:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/$1 [L]
</IfModule>
附:我希望你的文件是“.htaccess”(不是.htacess)
如果它仍然无效,请尝试通过在其顶部添加此文件来编辑index.php
文件:
<?php
echo $_SERVER['REQUEST_URI'];
die;
这必须向您显示htaccess正确地重写为index.php文件
如果仍然没有得到适当的工作,请联系托管支持。
从这里拍摄的这个片段非常感谢:https://gist.github.com/philipptempel/4226750
答案 3 :(得分:-1)
因为你提到了404错误。你能确保所有项目文件夹都有适当的权限来执行吗?
将权限设置为0755到项目文件夹及其所有子文件夹。
然后尝试一下。
答案 4 :(得分:-1)
要确保错误的部分是.htaccess
文件,您需要在路径上使用index.php
访问您的网站。
例如,您需要访问http://example.com/index.php/book而不是http://example.com/book。
如果可以访问第一个网址,那么您的.htaccess
可能不正确。
我通常在我的CodeIgniter项目中发送此.htaccess
:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/$1 [L]
</IfModule>
<IfModule !mod_rewrite.c>
ErrorDocument 404 /index.php
</IfModule>
最后,请确保您的Apache服务器中已激活rewrite
mod(如果您使用共享主机,请与您的托管服务提供商联系)。
要激活它,请运行以下命令:
sudo a2enmod rewrite
然后,重启服务:
sudo service apache2 restart
希望它有所帮助。
答案 5 :(得分:-1)
I needed to register 000webhost and check the subdomain structure for solving that problem. As I suspected, it's creates a folder for subdomain. Therefore your .htaccess file is not working correctly. You need to point subfolder as rewritebase:
DirectoryIndex index.php
RewriteEngine on
RewriteBase /sigede/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond $1 !^(index\.php|public|images|css|js|robots\.txt)
RewriteRule ^(.*)$ index.php?/$1 [L]