什么将我的.htaccess设置?

问题描述:

我目前使用CodeIgniter 3.它正在我的笔记本电脑上工作。 但是,当我上传到我的Centos 6.9服务器...我遇到一个错误。 我已经检查mod_rewrite是否已加载。什么将我的.htaccess设置?

I want it to be like this URL/controller/method (no index.php after URL) 

It shows me a 404 when i try to login which redirect me to this URL/gate/login 

I also set this.... 
$config['index_page'] = ''; 
$config['uri_protocol'] = 'REQUEST_URI'; 

My htaccess on /var/www/html/calllist 


<IfModule mod_rewrite.c> 
    RewriteEngine On 
    RewriteCond %{REQUEST_FILENAME} !-f 
    RewriteCond %{REQUEST_FILENAME} !-d 
    RewriteRule ^(.*)$ /calllist/index.php?/$1 [L] 
</IfModule> 


My httpd.conf 
DocumentRoot "/var/www/html" 

<Directory /> 
    Options FollowSymLinks 
    AllowOverride All 
</Directory> 

<VirtualHost *:80> 
    ServerAdmin [email protected] 
    DocumentRoot /var/www/html/calllist 
    ServerName www.xxxx.com 
    ErrorLog /var/www/html/calllist/error_log 
    CustomLog /var/www/html/calllist/requests.log common 
</VirtualHost> 
+0

我怀疑'/呼叫清单/ index.php'将是URL的一部分...你可能想重定向到'/ index.php'只要。 – arkascha

+0

http://URL/index.php/gate/login,它可以加载... 我需要正确的.htacess来隐藏这个index.php。 –

+0

通过CI 3,你是指CodeIgniter?如果使用'base_url()'函数发生这种情况,请确保在'application/config/config.php'中将'$ config ['index_page']'设置为空字符串。 – pxgamer

我解决了这个问题。 显然在httpd.conf上,还有另一行我需要设置为'全部'。

,我已将此添加到我的虚拟主机

<Directory "/var/www/html/calllist"> 
    Options FollowSymLinks 
    AllowOverride All 
    Order allow,deny 
    Allow from all 
</Directory> 
+0

显然你需要启用动态配置文件的解释,然后才能使用它们。这就是'AllowOverride'指令的作用。我建议你看看你使用的工具的文档。它写在那里遍地都是:-) – arkascha

+0

好了,在虚拟主机中的一个简单的'FallbackResource/index.php'而不是那些重写也可以为你工作。记住“目录/”指向/在文件系统中,永远不应该被授予访问权限。并且.htaccess不是必需的,如果您有权访问虚拟主机,请不要使用针对欠优先用户的配置。 –