【问题标题】:Remove index.php codeIgniter in xampp mac os 10.9 not work删除 xampp mac os 10.9 中的 index.php codeIgniter 不起作用
【发布时间】:2014-08-19 06:34:49
【问题描述】:

我已经使用 xampp 和 codeIgnitor 在 windows 基础机器上开发了一个系统,所以我将开发环境更改为 mac os 10.9 相同的系统给我错误 404。所以将 index.php 放入 URL 问题已解决。但我想知道它是如何发生的。因为我已经在 windows 环境中使用 htaccess 文件删除了 index.php。我想知道如何在 mac os 10.9 中删除 index.php。

这是我的 htaccess 文件内容。

RewriteEngine On

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.+)$ index.php?/$1 [L]

/Applications/XAMPP/xamppfiles/etc/httpd.conf 文件也编辑如下

  • 启用重写模块“LoadModule rewrite_module modules/mod_rewrite.so”
  • 更改用户名

    用户****** 组守护程序

  • 更改权限

    允许覆盖所有 要求所有授予

CodeIgnitor 配置文件也编辑如下

- change base url

    $config['base_url'] = 'http://localhost/ci2.2/';

 - Remove index.php

    $config['index_page'] = '';

 - Change URL Protocol

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

我将文件放在 /Applications/XAMPP/xamppfiles/htdocs/ci2.2 目录中

【问题讨论】:

    标签: macos .htaccess codeigniter mod-rewrite xampp


    【解决方案1】:

    试试这个 htacess 内容:

    RewriteEngine on
    RewriteCond $1 !^(index\.php|images|robots\.txt)
    RewriteRule ^(.*)$ /index.php/$1 [L]
    

    参考:http://ellislab.com/codeigniter/user-guide/general/urls.html

    如果您使用的是子目录,请将最后一行替换为:

    RewriteRule ^(.*)$ /[SUBDIRECTORY]/index.php/$1 [L]
    

    将 [SUBDIRECTORY] 替换为您的目录名称

    【讨论】:

    • 感谢 Amir 的快速响应。我也试试。但不行。我认为问题是 htaceess 在 Mac os 10.9 中不起作用。请指导我。再次感谢。
    • 在该示例中为 localhost/~username/site/site/index.php/welcome,在我的示例中为 localhost/ci2.2/index.php/welcome。所以他们说它在使用 RewriteBase /~username/YOURPath 时有效。所以我使用了 RewriteBase /ci2.2 。但这对我不起作用:(
    【解决方案2】:

    在我的情况下,以下代码可以正常工作

     RewriteEngine On
     RewriteBase /projects/hc/homecare/trunk/homecare 
     RewriteCond %{REQUEST_FILENAME} !-f
     RewriteCond %{REQUEST_FILENAME} !-d
     RewriteCond $1 !^(index\.php|images|robots\.txt|css|docs|js|system)
     RewriteRule ^(.*)$ /projects/hc/homecare/trunk/homecare/index.php?/$1 [L]
    

    参考:link

    【讨论】:

      猜你喜欢
      • 2021-04-11
      • 2017-04-04
      • 2014-08-12
      • 2013-12-29
      • 2019-01-14
      • 2020-07-30
      • 2012-03-26
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多