Apache .htaccess文件重写的次数超出了应有的次数

Apache .htaccess文件重写的次数超出了应有的次数,apache,.htaccess,mod-rewrite,url-rewriting,friendly-url,Apache,.htaccess,Mod Rewrite,Url Rewriting,Friendly Url,PHP应用程序中的.htaccess文件应该将所有请求从example.com/playlists/[ID]重定向到example.com/playlists/display.PHP?ID=[ID],但是.htaccess文件也会影响其他文件。.htaccess系统在example.com/playlists/edit的末尾追加了/?id=edit,这会影响页面的显示方式 我的目录结构: Playlists |-- index.php `-- playlists |-- index.ph

PHP应用程序中的.htaccess文件应该将所有请求从
example.com/playlists/[ID]
重定向到
example.com/playlists/display.PHP?ID=[ID]
,但是.htaccess文件也会影响其他文件。.htaccess系统在
example.com/playlists/edit
的末尾追加了
/?id=edit
,这会影响页面的显示方式

我的目录结构:

Playlists
|-- index.php
`-- playlists
    |-- index.php
    |-- display.php <----------------[ THIS FILE TAKES THE .HTACCESS REDIRECTED REQUESTS ]----------------
    |-- .htaccess <----------------[ THIS IS THE PROBLEM FILE ]-------------------
    `-- edit
        `-- index.php
我要重定向的URL的唯一部分是
example.com/playlists/
之后的部分,而不是其他部分,以确保规则不会应用于任何其他内容,也不会覆盖任何现有目录或文件

URL
example.com/playlists/foobar
已成功重写为
example.com/playlists/display.php?id=foobar


有人有什么想法或建议吗?

您的.htaccess文件将编辑作为display.php的id

您需要指定您希望编辑首先转到文件夹,否则,请使用原始规则

您可以将文件夹移动到根目录并使用以下方法:

RewriteRule ^edit/?$ edit/index.php [L]
RewriteRule ^([A-Za-z0-9_\-\+]+)/?$ display.php?id=$1 [L]

它将是
index.php
,并将
L
标志放在它们两个上。感谢您捕捉到了这一点,是的,
L
完美地指定了它们是最后一个要使用的规则。非常感谢,这有助于堆。
RewriteRule ^edit/?$ edit/index.php [L]
RewriteRule ^([A-Za-z0-9_\-\+]+)/?$ display.php?id=$1 [L]