2014-01-21 38 views
2

我的项目在我的服务器上的本地成功,但不工作的工作,我有一个Linux服务器在HostGator的如何使用codeigniter中的linux服务器上的.htaccess从url中删除index.php?

默认控制器是托管工作正常,但例如:

example.com/contact-us不工作会重定向到服务器的404页找不到网页,但example.com/index.php/contact-us工作

我的.htaccess代码:

RewriteEngine on 
RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteRule .* index.php/$0 [PT,L] 

配置:

$config['base_url']  = 'http://linksture:2000/websitebusinessforsale.com/project'; 
$config['index_page'] = ''; 
$config['uri_protocol'] = 'REQUEST_URI'; 

我不知道什么问题,预先感谢您的回复

+0

可能重复http://stackoverflow.com/questions/15217862/codeigniter-application-works-on-hostgator-but-not-another-web-host – tomexsans

+0

@tomexsans不适合我... – darshan

回答

0

试试这个

RewriteEngine On 
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteCond %{REQUEST_FILENAME} !-f 
RewriteRule ^(.*)$ index.php?q=$1 [L,QSA] 
+0

不工作... :(相同的问题.. – darshan

0

这很可能是你的代码是一个文件夹内从apache根。如果是这样的话,你需要写

/project/index.php/$0 

因此,如果您上传所有的代码到的/ var/WWW/myproject的,然后使用

/myproject/index.php/$0 
+0

我不能理解你写什么代替/项目? – darshan

0

我知道也许你找到一个解决方案这个问题, 问题出在Apache配置中。

首先,找到配置文件,(在我的情况,我用Linux Mint的) 配置文件应该是下/etc/apache2/sites-available/

继续编辑default.conf文件(这取决于你的机器上,我在我的机器它通过使用此命令命名000-default.conf) 编辑文件sudo gedit 000-default.conf

将这个命令虚标签外

<Directory /var/www/html> 
    Options Indexes FollowSymLinks MultiViews 
    AllowOverride All 
    Order allow,deny 
    allow from all 
</Directory> 

保存并使用sudo service apache2 restart

重新启动您的apache因此,您必须在您的机器上找到apache配置文件,然后执行相同的步骤。

相关问题