如何使用.htaccess重定向到另一个同名子目录


How to redirect to another subdirectory with same name with .htaccess

我想将文件夹A中的文件重定向到具有相同文件名的文件夹B。例如。yourdomain.com/folderA/nosedinger.php到yourdomain.com/folderB/nosedinger.php

.htaccess位于yourdomain.com/folderA/.htaccess.

我试了以下方法,但效果不佳。需要帮助。完全不知道.htaccess中的代码到底是什么意思。

Options +FollowSymLinks -MultiViews
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_URI} !^/folderB/ [NC]
RewriteCond %{REQUEST_URI} ^/(.*)$
RewriteRule ^ /folderB/$2 [R=301,L]

要从foldera重定向到folderb,您可以在其他规则之上使用以下重定向

RedirectMatch ^/foldera/(.*)$ /folderb/$1

这应该是您所需要的:

RewriteEngine On 
RewriteRule /folderA/(.*) /folderB/$1 [R=302,NC]

可能:

RewriteRule ^folderA(/.*)?$ folderB$1 [R=302,NC]