【发布时间】:2014-06-10 20:28:03
【问题描述】:
我已经尝试了几乎所有我能想到的东西,我基本上已经将我的项目从 Mac OS 转移到 Windows OS 网络服务器(本质上是测试)。当我从我的服务器访问任何其他页面时,我收到“页面未找到”错误,但是如果我添加 index.php/location,它会起作用,无论如何这里是我的一些设置:
最初,我通过在响应为 true 的条件语句中添加以下内容来检查 mod_rewrite 是否已启用。
这是我的 .htaccess 文件,它位于我的项目的主目录中(带有 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>
也试过RewriteRule ^(.*)$ index.php/$1 [L],写在<ifModule>标签之外。
以下是我的一些 codeigniter 设置:
$config['base_url'] = '';
$config['index_page'] = '';
$config['uri_protocol'] = 'AUTO';
我还尝试在 index_page 中包含 index.php 并尝试将 REQUEST_URI 用于 uri_protocol,但似乎没有任何效果。
旁注:它在我的 mac 和 linux (Raspberry Pi) 上完美运行。
你能建议任何替代方法或发现我错过的东西吗?
编辑: httpd.conf 我做了以下
<directory />
Options All
AllowOverride All
</directory>
AllowOverride None 的所有实例都已更改为 AllowOverride All
以下内容已取消注释/启用:
LoadModule rewrite_module modules/mod_rewrite.so
【问题讨论】:
-
我不得不问(因为这里有另一个问题有同样的问题)。你确定你在 Windows 服务器上使用 Apache 吗?
-
我正在使用 Windows 版 MAMP Beta,我希望 Apache 能够正常工作,因为我可以加载主页 :)
-
只是检查——这里的另一个问题有人想知道为什么他们的 htaccess 不起作用但他们使用的是 IIS。说到 htaccess 不工作,你确定它正在被处理吗?默认情况下,某些设置不处理 .htaccess 文件。我经常发现故意犯错误并确保收到 500 错误很有用。
-
也尝试删除 ifmodule 语句。也许没有安装 mod_rewrite - 我知道您尝试通过 PHP 对其进行测试,但最好不要使用 PHP,直到您知道您已正确处理 mod_rewrite 和 .htaccess。
-
我试过了,没有任何反应
标签: php apache .htaccess codeigniter mod-rewrite