简体   繁体   中英

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

I want to redirect my file in folder A to folder B with the same file name. EG. yourdomain.com/folderA/nosedigger.php to yourdomain.com/folderB/nosedigger.php

The .htaccess is at yourdomain.com/folderA/.htaccess.

I tried the following but it does not work like a charm. Need help. Totally have no clue what the codes in .htaccess really mean.

Options +FollowSymLinks -MultiViews

RewriteEngine On
RewriteBase /

RewriteCond %{REQUEST_URI} !^/folderB/ [NC]
RewriteCond %{REQUEST_URI} ^/(.*)$
RewriteRule ^ /folderB/$2 [R=301,L]

this should be all you need:

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

maybe:

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

要从foldera重定向到folderb,您可以使用高于其他规则的以下重定向

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM