Home>
What i am thinking

We are thinking of moving the site "example.com" operated by WordPress to a subdomain such as "2020.example.com".

I moved more than 10,000 pages, and I set 301 redirect in .htaccess, but I would like to exclude the top page and management screen for the convenience of operation.

Code I tried

The method set in .htaccess is as follows.

RewriteEngine On
RewriteBase /
#Exclusion setting (management screen)
RewriteCond% {REQUEST_URI}! (^/Wp-admin /)
RewriteCond% {REQUEST_URI}! \ .css $
RewriteCond% {REQUEST_URI}! \ .js $
RewriteCond% {REQUEST_URI}! \ .jpg $
RewriteCond% {REQUEST_URI}! \ .gif $
RewriteCond% {REQUEST_URI}! \ .png $
#Exclusion setting (top page)
RewriteCond% {REQUEST_URI}! (^ /)
#redirect
RewriteRule ^ (. *) $Https://2020.example.com/ [R = 301, L]
Contents of question

With the above settings, the top page is brought to the exclusion, so all the subdirectories are excluded, which is a problem.

Is there a way to exclude only the top page "/" with the 301 redirect setting?

Sorry to trouble you, but thank you.

  • Answer # 1

    It seems that the end of the line and the match are described in other parts,

    RewriteCond% {REQUEST_URI}! ^/$


    So what happens?

  • Answer # 2

    RewriteCond each[OR]In Tsuken and Ikan

    Mistake

    ^ /? $