htaccess的重写规则不工作正确的MAC重写、正确、规则、工作

2023-09-02 00:24:12 作者:|▍尘世如戏丶逢场做戏

我有我的Mac书亲豹一个网站项目,而我使用内置的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>

现在的问题是,当我想打开像一个网站 本地主机/〜用户名/网站/网站/的index.php /欢迎,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.

但是,当我试图进入网站,如网站/欢迎阿帕奇给了我以下错误:

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

未找到

所请求的网址用户/用户名/网站/网站/的index.php /欢迎在此服务器上找到。

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

现在的问题是阿帕奇得到这个像它确实是一个文件和错误陈述给它在文件系统的方式,但这一要求就必须获取到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的不为我的狮子工作。

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]