Score:1

htaccess: I can't redirect to nested subfolders correctly on the WordPress app

US flag
user1034636

I have a multilingual WordPress site that has two languages: en and tr, It's site A.

I wanna put my other WordPress site inside /tr/shop/ folder, It's site B.

Just need only these rules:

  • /en/anything/ goes to site A (also /en/)
  • /tr/anything/ goes to site A (also /tr/)
  • /tr/shop/ goes to site B inside the /tr/shop subfolder.

Currently:

  • If visitors go to /en/ or /en/anything, It's OK.
  • If visitors go to /tr/shop/, they see site B, It's OK. Because the folder exists.
  • Visitors who go to /tr/* see a 404 error. Because /tr/ is a physical folder but empty. It's just a language prefix, not a physical folder. I need to exclude /tr/ folder from requests.

How can I do it?

My current .htaccess is below but not working.

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
RewriteBase /

# Exclude /tr/ from rewriting
RewriteRule ^tr(/.*)?$ - [L]

RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]

# Beginning of shop part
RewriteRule ^tr/shop(/.*)?$ /tr/shop/$1 [L]
RewriteRule ^tr(/.*)?$ /index.php [L]
# End of shop part
</IfModule>
kz flag
[Cross-site post on StackOverflow](https://stackoverflow.com/questions/76687238/htaccess-i-cant-redirect-to-nested-subfolders-correctly-on-the-wordpress-app) where this question already has an answer.
Burak Ibis avatar
ls flag
It's also solved on [Cross-site post on StackOverflow](https://stackoverflow.com/questions/76687238/htaccess-i-cant-redirect-to-nested-subfolders-correctly-on-the-wordpress-app?noredirect=1#76689144) ❤️ thanks MrWhite!
jp flag
I’m voting to close this question because it already has an answer on another site.
I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.