【发布时间】:2014-09-23 14:14:03
【问题描述】:
不久前,我在大部分项目中都使用了 CodeIgniter。我正在回到事物的摇摆中并遇到一些颠簸。我现在在 Mac OSX Mavericks 上开发并使用 MAMP 作为我的 Apache 服务器。一切似乎都运行良好,但我始终无法摆脱 URL 中的 index.php。我已将 .htaccess 文件添加到项目的根目录中。这是文件:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /ez-recruits/
#Removes access to the system folder by users.
#Additionally this will allow you to create a System.php controller,
#previously this would not have been possible.
#'system' can be replaced if you have renamed your system folder.
RewriteCond %{REQUEST_URI} ^system.*
RewriteRule ^(.*)$ /index.php?/$1 [L]
#When your application folder isn't in the system folder
#This snippet prevents user access to the application folder
#Submitted by: Fabdrol
#Rename 'application' to your applications folder name.
RewriteCond %{REQUEST_URI} ^application.*
RewriteRule ^(.*)$ /index.php?/$1 [L]
</IfModule>
<IfModule !mod_rewrite.c>
# If we don't have mod_rewrite installed, all 404's
# can be sent to index.php, and everything works as normal.
# Submitted by: ElliotHaughin
ErrorDocument 404 /index.php
</IfModule>
我不太了解如何制作这些文件,所以通常我只是从 CodeIgniters 网站获取它们。我在 URL 中没有 index.php 时收到 404 错误,如果我手动输入它,页面将正常加载。此外,我在 Firefox 中进行开发,并且在 URL 中没有 index.php 的情况下收到错误消息“Firefox 无法理解该地址”。我确实在 Apache 服务器上激活了 mod_rewrite。我已在索引页面的配置文件中删除了 index.php,并将 base_url 设置为
$config['base_url'] = 'localhost:8888/ez-recruits';
我做了一些研究,发现更改httpd.conf文件对其他人有帮助,因此我将其中的一部分更改为:
<Directory />
Options FollowSymLinks
AllowOverride All
Order deny,allow
Deny from all
</Directory>
但它什么也没改变。有谁知道我可能做错了什么,或者这只是一个 Mac 问题?此外,使用所有这些配置,我是否会难以与在 Windows 机器上开发的其他人一起开发?
提前致谢。
【问题讨论】:
标签: php apache .htaccess codeigniter mod-rewrite