I am trying to rewrite a URL to remove two subdirectories and display the page in the root directory instead. This the code I use in my .htaccess:
RewriteRule ^page$ subdirectoryone/subdirectorytwo/page [NC,QSA,L]
This is my complete .htaccess file in the root directory:
Options +FollowSymLinks
RewriteEngine on
RewriteCond %{HTTPS_HOST} ^mysite.com
RewriteRule (.*) https://www.mysite.com/$1 [R=301,L]
RewriteCond %{HTTP_HOST} ^mysite.com
RewriteRule (.*) https://www.mysite.com/$1 [R=301,L]
RewriteCond %{SERVER_PORT} !=443
RewriteRule ^(.*)$ https://www.mysite.com/$1 [R=301,L]
# remove trailing slashes
RewriteRule (.*)/$ $1 [L,R=301]
RewriteRule ^page$ subdirectoryone/subdirectorytwo/page [NC,QSA,L]
This is the .htaccess in the first subddirectory:
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /subdirectoryone/
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /subdirectoryone/index.php [L]
</IfModule>
# END WordPress
However, when I open the URL www.mysite.com/page it displays an error 404. By the way: I am using Wordpress, installed in the first subdirectory – does that make any difference?
Also, it works when I only remove the first of the two subdirectories.
Any ideas? Thanks in advance!