gpt4 book ai didi

php - htaccess 从 index.php 重定向到/仅在特定文件夹中

转载 作者:行者123 更新时间:2023-12-04 16:47:34 25 4
gpt4 key购买 nike

我想在我的 htaccess 文件中创建重定向。从带有 index.php 的 url 到没有 index.php 的页面,但仅针对一个特定文件夹“catalog”。

例如:

/catalog/some_folder/index.php/catalog/some_folder/

/catalog/some_folder/etc/index.php/catalog/some_folder/etc/

像这样的 URL /catalog2/some_folder/index.php 不必重定向

我尝试添加这些行(本地主机,因为它是 xampp):

  RewriteCond %{REQUEST_URI} /catalog/+[^\.]+index.php$
RewriteRule ^index\.php$ localhost/$1 [R=301,L]

但这没有用。我怎样才能强制它正常工作?

最佳答案

您可以在 root .htaccess 中使用此规则:

# remove index.php
RewriteCond %{THE_REQUEST} /index\.php [NC]
RewriteRule ^(catalog/.+)index\.php$ /$1 [L,R=302,NC,NE]

关于php - htaccess 从 index.php 重定向到/仅在特定文件夹中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37514303/

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