2016-02-18 81 views
1

这是我上传到在线服务器的第一个应用程序。我在CodeIgniter 3.0.1上创建了应用程序并将其上载到000webhost.com。但问题是,我的链接没有被路由。我在网上检查过,我的.htacess文件似乎是正确的。我检查了这个问题My .htaccess file is not working,我遇到了和他一样的问题,但是正确的答案没有奏效。CodeIgniter不在服务器上路由

我的继承人.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] 
+1

whatz你的错误?你想达到什么? –

+0

您需要在根文件夹中为css,js等创建一个名为“public”的文件夹。 –

+0

您能否提供错误信息?是500错误还是别的? –

回答

1
  1. 你能确保你已经创建了一个特殊的“控制器” &它的“法”到你想的路线?我的意思是你可以从字面上验证他们的拼写?

  2. 你能也尝试创建一个规则:

$route['club'] = 'welcome/index';

你可以看到,如果上述规则适用与否?你有没有其他的控制器的名字'club.php'?

+0

是的。一切工作正常我的本地服务器上。它只是在网络主机上不起作用 –

+0

上述步骤2不起作用? – tovishalck

+0

不,它没有工作 –

-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文件。
如果仍然无法正常工作,请与托管支持联系。

BTW从这里取这个片段中,有许多感谢:https://gist.github.com/philipptempel/4226750

+0

我试过.htaccess,它没有工作。 echo $ _SERVER ['REQUEST_URI'];返回 - > \ –

+0

@RosárioPereiraFernandes在所有情况下?你试过在浏览器中打开:http://yoursite.com/something? – num8er

-1

既然你提到的404错误。你能确保所有的项目文件夹都有适当的执行权限吗?

将权限设置为0755到项目文件夹及其所有子文件夹。

然后试试看。

-1

为了确保错误的部分是.htaccess文件,您需要在路径上使用index.php访问您的网站。

例如,您需要访问http://example.com/index.php/book而不是http://example.com/book

如果可以访问第一个URL,那么很可能是您的.htaccess不正确。

我通常在我的笨工程船舶此.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> 

而在去年,请确保您的rewrite国防部在Apache服务器启动(请联系您的托管服务提供商如果使用共享的主机)。

要激活它,运行这个命令:

sudo a2enmod rewrite 

然后,重新启动服务:

sudo service apache2 restart 

希望它能帮助。

-1

我需要注册000webhost并检查子域结构来解决这个问题。正如我怀疑的那样,它为子域创建了一个文件夹。因此,您的.htaccess文件无法正常工作。您需要将子目录作为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] 
相关问题