Home>

When I set the redirect to a certain directory, I want to exclude it only when a specific file in the directory is accessed.
The location of htaccess is located in root.
The folder structure is as follows, but how is it written differently?

File location

root/.htacess
root/kodomo/tamago.html
root/kodomo/karaage.html
root/chugoku/men.html
root/itaria/pasta.html

RewriteEngine On
RewriteBase /
RewriteCond% {REQUEST_URI}! ^/Kodomo/tamago.html $
RewriteCond% {REQUEST_URI}! ^/Kodomo/karaage.html $
RewriteRule kodomo (. *) Https://dummy.com/kids/ [R = 301]
RewriteCond% {REQUEST_URI}! ^/Chugoku/men.html $
RewriteRule chugoku (. *) Https://dummy.com/china/ [R = 301]
RewriteCond% {REQUEST_URI}! ^/Itaria/pasta.html $
RewriteRule itaria (. *) Https://dummy.com/italy/ [R = 301]
What happens when you visit

First processing phenomenon (processing I want to achieve)

You can redirect ◯
https://sample.com/kodomo/

https://dummy.com/kids/

Excluded ◯
https://sample.com/kodomo/tamago.html


Symptom after the second processing (processing)

RewriteCond% {REQUEST_URI}! ^/chugoku/men.html $
RewriteCond% {REQUEST_URI}! ^/Itaria/pasta.html $

You can redirect ◯
https://sample.com/chugoku/

https://dummy.com/china/

Not excluded x
https://sample.com/chugoku/men.html

https://dummy.com/china/

  • Answer # 1

    This led to self-solving. It seemed to be a problem that occurred without RewriteCond being enabled.
    .Htaccess is placed in each directory, and it can be realized safely with the following description.

    
    RewriteEngine on
    RewriteCond% {REQUEST_URI}! ^ Men.html
    RewriteRule ^ $https://dummy.com/china/ [R = 301, L]
    RewriteCond% {REQUEST_URI}! ^ Men.html
    RewriteRule (. *). Index.html https://dummy.com/china/ [R = 301, L]
    


    Thank you for your answer.