0

我在将所有请求定向到一个 php 文件时遇到问题。我以前用过这个设置。

C:/path/app/.htaccess 中的配置

DirectoryIndex  disabled

RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ web/index.php    [QSA,L]

错误日志

[Fri Apr 19 07:04:04.582078 2013] [rewrite:trace3] [pid 4804:tid 1284] mod_rewrite.c(466): [client 127.0.0.1:65174] 127.0.0.1 - - [127.0.0.1/sid#238bf48][rid#2d9e170/initial] [perdir C:/path/app/] strip per-dir prefix: C:/path/app/ -> 
[Fri Apr 19 07:04:04.582078 2013] [rewrite:trace3] [pid 4804:tid 1284] mod_rewrite.c(466): [client 127.0.0.1:65174] 127.0.0.1 - - [127.0.0.1/sid#238bf48][rid#2d9e170/initial] [perdir C:/path/app/] applying pattern '^(.*)$' to uri ''
[Fri Apr 19 07:04:04.582078 2013] [rewrite:trace2] [pid 4804:tid 1284] mod_rewrite.c(466): [client 127.0.0.1:65174] 127.0.0.1 - - [127.0.0.1/sid#238bf48][rid#2d9e170/initial] [perdir C:/path/app/] rewrite '' -> 'web/index.php'
[Fri Apr 19 07:04:04.582078 2013] [rewrite:trace3] [pid 4804:tid 1284] mod_rewrite.c(466): [client 127.0.0.1:65174] 127.0.0.1 - - [127.0.0.1/sid#238bf48][rid#2d9e170/initial] [perdir C:/path/app/] add per-dir prefix: web/index.php -> C:/path/app/web/index.php
[Fri Apr 19 07:04:04.582078 2013] [rewrite:trace1] [pid 4804:tid 1284] mod_rewrite.c(466): [client 127.0.0.1:65174] 127.0.0.1 - - [127.0.0.1/sid#238bf48][rid#2d9e170/initial] [perdir C:/path/app/] internal redirect with C:/path/app/web/index.php [INTERNAL REDIRECT]

并且文件 C:/path/app/web/index.php 存在并且只是 phpinfo()。

<?php

phpinfo();

如果我获得了日志权限,则重定向按预期工作,但我仍然得到 404。

有什么想法可能是这里的问题吗?

4

1 回答 1

1

您的重写规则需要知道文件夹库(默认为 Web 服务器根目录)。

所以你需要在RewriteBase /app/之后设置RewriteEngine on

RewriteEngine on
RewriteBase /app/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ web/index.php    [QSA,L]
于 2013-04-19T15:01:04.723 回答