.htaccess rewriterule 在 mac 上无法正常工作 [英] .htaccess rewriterule not working correct on mac

查看:45
本文介绍了.htaccess rewriterule 在 mac 上无法正常工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在我的 mac book pro leopard 上有一个网站项目,我使用内置的 apache2 和 php.我已经在 httpd.conf 和 user.conf 中进行了配置以使用 htaccess.更改完成如下:

I have a website project on my mac book pro leopard, and I am using built in apache2 and php. I've made my configurations in both httpd.conf and user.conf to use htaccess. Changes done like :

LoadModule rewrite_module /usr/lib/apache2/modules/mod_rewrite.so

<Directory >
    AllowOverride All
</Directory>

问题是当我想打开一个网站时localhost/~username/site/site/index.php/welcome,index.php做一些操作,找到合适的控制器和合适的页面.

The problem is when i want to open a site like localhost/~username/site/site/index.php/welcome, index.php does some operations and finds the right controller and the right page.

但是当我尝试进入像 site/welcome 这样的网站时,apache 给了我以下错误:

But when I try to enter site like site/welcome apache gives me the following error :

未找到

在此服务器上找不到请求的 URL Users/username/Sites/site/index.php/welcome.

The requested URL Users/username/Sites/site/index.php/welcome was not found on this server.

问题是 apache 把它当成一个文件,错误语句以文件系统的方式给出它,但这个请求必须被提取到 index.php.

The problem is apache gets this like it is indeed a file and the error statement gives it in a file system way, but this request must be fetched to index.php instead.

我的 .htaccess 文件看起来像这样

my .htaccess file looks like this

<ifModule mod_rewrite.c>
RewriteEngine On

RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php/$1 [NC,QSA,L]
</ifModule>

令我烦恼的是,此配置适用于 Linux 和 Windows,但不适用于 Mac.我觉得注定要失败:)

What bothers me that this configuration works on both Linux and Windows but does not work on Mac. I feel doomed : )

推荐答案

我也遇到了同样的问题!DocumentRoot"在 Lion 中对我不起作用.

I met the same problem too! 'DocumentRoot' doesn't work for me in Lion.

但这有效:

RewriteEngine On

RewriteBase /~username/YOURPath

RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php/$1 [NC,QSA,L]

这篇关于.htaccess rewriterule 在 mac 上无法正常工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆