大网数据广告活动
服务器运维问答

FallbackResource in subdirectory

· 52CE 我爱测

I manage a large number of PHP applications using front controller s and the following htaccess file: FallbackResource /index.php Yes, that is the entire file (for each application)! However, a few of the sites are in subfolders,…

问题原文

原帖链接 · Moshe Katz · CC BY-SA 3.0

I manage a large number of PHP applications using front controllers and the following htaccess file:

FallbackResource /index.php

Yes, that is the entire file (for each application)!

However, a few of the sites are in subfolders, necessitating the following change:

FallbackResource /subfolder/index.php

As you could probably guess, the / at the beginning means that the path is relative to the site/vhost, and here the path needs to be relative to the directory.

(If I were using mod_rewrite for this instead of mod_dir, I would have to add a RewriteBase to each subdirectory as needed, in a similar fashion.)

I thought that I could get around this by doing:

FallbackResource index.php # No slash!

However, when the site's rewrites contain slashes, for example, if the application is /store/ and the path within it is products/1234, then Apache looks for /store/products/index.php instead of /store/index.php and returns a 500 with the following message in the log:

Request exceeded the limit of 10 subrequest nesting levels due to probable configuration error. Use 'LimitInternalRecursion' to increase the limit if necessary. Use 'LogLevel debug' to get a backtrace.

I would have thought that the FallbackResource path is relative to the .htaccess file in which it is configured, but it seems that it is actually relative to the requested URL.

Is there a way to have FallbackResource act the way that I expected?


I can use it the way it is if that's the answer, but it would make it a lot easier to manage the sites that I have if this can be done. The sites use the same basic code with different themes and database connections, and the way it works now I have to modify the htaccess file every time we deploy a new version of the code (because it is checked into Git). If we can make it that someone doesn't have to remember to make this modification every time, that would be really great.

已采纳解答

原帖链接 · Moshe Katz · CC BY-SA 3.0

The sites about which I originally asked this question are no longer live, but here's what i ended up doing.

I ended up moving these sites to a server running Nginx, where all configuration is done in the config files of the server using a try_files directive. It was much easier to manage that way.

摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。

资料来源与适用范围

资料来源
Server Fault
适用范围
以原帖系统、软件版本与发布日期为准(2014-04-10)
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 3.0

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。