gpt4 book ai didi

apache - mod_rewrite - 防止多次重定向

转载 作者:行者123 更新时间:2023-12-02 05:45:25 24 4
gpt4 key购买 nike

我的文件夹结构:

- nameoftherootfolder
-- app
-- public
--- .htaccess
--- index.php

现在我遇到的问题是,在某些情况下,我的 apache 内部重写过于频繁,导致我收到 500 服务器错误,日志如下:

[Wed Jan 05 17:51:54 2011] [error] [client 127.0.0.1] Request exceeded the limit of 3 internal redirects due to probable configuration error. Use 'LimitInternalRecursion' to increase the limit if necessary. Use 'LogLevel debug' to get a backtrace.
[Wed Jan 05 17:51:54 2011] [debug] core.c(3046): [client 127.0.0.1] r->uri = /nameoftherootfolder/public/index.php
[Wed Jan 05 17:51:54 2011] [debug] core.c(3052): [client 127.0.0.1] redirected from r->uri = /nameoftherootfolder/public/index.php
[Wed Jan 05 17:51:54 2011] [debug] core.c(3052): [client 127.0.0.1] redirected from r->uri = /nameoftherootfolder/public/index.php
[Wed Jan 05 17:51:54 2011] [debug] core.c(3052): [client 127.0.0.1] redirected from r->uri = /nameoftherootfolder/nothere/

我的.htaccess:

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} -s [OR]
RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^.*$ - [NC,L]
RewriteRule ^.*$ index.php [NC,L]

index.php 处理所有请求,并处理访问的 url 错误的情况,例如不存在。

如果访问的网址存在,但网址“错误”,它会起作用,我会收到该错误。自从我设置了 Apache 别名后,我就得到了这个:

Alias /nameoftherootfolder/ "C:/somepathshere/WAMP/www/nameoftherootfolder/public/" 

<Directory "C:/somepathshere/WAMP/www/nameoftherootfolder/public/">
Options Indexes FollowSymLinks MultiViews
AllowOverride all
Order allow,deny
Allow from all
</Directory>

我现在如何防止 Apache 发生过多的内部重定向?可能有 RewriteCond 吗?我正在使用 Apache 2.2.11。

编辑:

如果我将 index.php/ 放入 uri 中,它可以工作,但这对 SEO 不友好,对用户不友好,而且看起来很糟糕,例如要求。http://localhost/nameoftherootfolder/index.php/nothere/http://localhost/nameoftherootfolder/index.php/index/

编辑#2:

添加后

RewriteBase /nameoftherootfolder/

它的工作原理知道。

最佳答案

添加后

RewriteBase /nameoftherootfolder/

现在可以使用了。

关于apache - mod_rewrite - 防止多次重定向,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4606943/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com