dongzhan9100 2014-06-10 20:28
浏览 23

由于htaccess而找不到页面

I've tried pretty much everything i can think of, I've basically moved from Mac OS to Windows OS webserver with my project (testing essentially). When i access any other page from my server I get the "Page Not Found" error, however it works if i add index.php/location, anyway here is some of my settings:

Initially i have checked if mod_rewrite is enabled by adding this: in_array('mod_rewrite', apache_get_modules()) to a conditional statement which responded as true so i know mod_rewrite is in face enabled.

Here is my .htaccess file which is located in the main directory of my project (with index.php):

<IfModule mod_rewrite.c>
    Options +FollowSymLinks 
    Options -Indexes 
    DirectoryIndex index.php 
    RewriteEngine on 
    RewriteCond $1 !^(index\.php|resources|images|css|js|robots\.txt|favicon\.ico) 
    RewriteCond %{REQUEST_FILENAME} !-f 
    RewriteCond %{REQUEST_FILENAME} !-d 
    RewriteRule ^(.*)$ index.php?/$1 [L,QSA]
</IfModule>

Have also tried as RewriteRule ^(.*)$ index.php/$1 [L] and written it outside the <ifModule> tags.

Here are some of my codeigniter settings:

$config['base_url'] = '';
$config['index_page'] = '';
$config['uri_protocol'] = 'AUTO';

I have also tried including the index.php in the index_page and tried REQUEST_URI for the uri_protocol and nothing seems to be working.

Sidenote: It runs perfectly on my mac and linux (Raspberry Pi).

Can you suggest any alternative methods or spot something I've missed.

EDIT: httpd.conf i have done the following

<directory />
  Options All
  AllowOverride All
</directory>

ALL instances of AllowOverride None have been changed to AllowOverride All

The following has been uncommented/enabled:

LoadModule rewrite_module modules/mod_rewrite.so
  • 写回答

1条回答 默认 最新

  • dongxi1965 2014-06-10 20:33
    关注

    Do not touch your default .htaccess file in php.

    1. Make a new file in your codeigniter root directory named ".htaccess"
    2. Paste below code into this new file.
    RewriteEngine On
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.*)$ /leo/index.php/$1 [L]
    

    Save it and it should work now.

    评论

报告相同问题?

悬赏问题

  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 对于相关问题的求解与代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 信号傅里叶变换在matlab上遇到的小问题请求帮助
  • ¥15 保护模式-系统加载-段寄存器
  • ¥15 电脑桌面设定一个区域禁止鼠标操作
  • ¥15 求NPF226060磁芯的详细资料