.htaccess redirect by url-ending to subfolder

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP



.htaccess redirect by url-ending to subfolder



In my WordPress installation I'm trying to redirect some urls into a virtual subdirectory. Urls with a special ending (/ophp/ and /ohtm/) should go into the directory /html/



For example


https://www.example.com/books/tipps18/ophp/
https://www.example.com/poems/part9/ohtm/



should become


https://www.example.com/html/books/tipps18/ophp/
https://www.example.com/html/poems/part9/ohtm/



I entered the following code in my .htaccess


<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %REQUEST_URI !^/html/
RewriteCond %REQUEST_URI ^.*/(ohtm|ophp)/$
RewriteRule ^(.*)$ /html/$1 [R=301,L]
</IfModule>



But although I checked this with the online htaccess tester, on my server this does not work and brings a 404 error.
Is my code wrong?









By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Popular posts from this blog

Firebase Auth - with Email and Password - Check user already registered

Dynamically update html content plain JS

Creating a leaderboard in HTML/JS