【问题标题】:Getting htaccess to work in CodeIgniter on Mac让 htaccess 在 Mac 上的 CodeIgniter 中工作
【发布时间】:2014-11-08 14:55:52
【问题描述】:

我在运行 Yosemite 的 Mac 上使用网络共享。我的user.conf的配置是:

<Directory "/Users/someuser/Sites/"> 
       AddLanguage en .en 
       LanguagePriority en 
       ForceLanguagePriority Fallback 
       Options FollowSymLinks Indexes MultiViews 
       AllowOverride All 
       Order allow,deny 
       Allow from localhost 
       Require all granted 
 </Directory>

对于保存在/Sites/myproject/ 的项目,我无法让.htaccess 工作。我必须在我不想要的 URL 中附加 index.php

【问题讨论】:

  • 我有同样的问题,一个技巧与我一起工作,只需使用 php 开发服务器来服务它将运行的应用程序。 cd 进入你的项目根目录和php -S localhost:8888 并查看
  • @Saqueib:还是不适合我。
  • 在终端中运行php --ini 并编辑加载的文件,搜索mod_rewrite 并取消注释模块(从开始删除#)和restart apache

标签: php macos .htaccess codeigniter osx-yosemite


【解决方案1】:

你可以试试这个在 mac 上为我工作。

<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /

    #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]

    #Checks to see if the user is attempting to access a valid file,
    #such as an image or css document, if this isn't true it sends the
    #request to index.php
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    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>

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2015-08-11
    • 2011-12-02
    • 2016-03-24
    • 2016-03-01
    • 2012-04-29
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多