I've checked on previous posts but my problem seems to not be covered by any previous answer.

I have WP installed into a subfolder


and a page password protected


What I need is the page working with


I've added on functions.php

//Rewrite Rules
add_rewrite_rule('thepage/', 'sub-folder/thepage/', 'top');

and tried

//Rewrite Rules
add_rewrite_rule('^thepage/', 'sub-folder/thepage/', 'top');

//Rewrite Rules
add_rewrite_rule('/thepage/', '/sub-folder/thepage/', 'top');

But nothing has worked. This is the first time I've use this function. What am I doing wrong?


The second argument of add_rewrite_rule is not a path, it the query string you want WordPress executes. This should work for example.com/sub-folder/thepage/ (change page_id with ID of your page):

add_rewrite_rule('thepage/', 'index.php?page_id=12');

or with page slug:

add_rewrite_rule('thepage/', 'index.php?pagename=thepage');

As you have WordPress in a subdirectory and you want to rip out the directoy name, you have to properly cofigure WordPress in sudirectory.

If you want all WordPress URLs in the format example.com/sub-folder/ and only rip out "sub-folder" for "thepage" you have to configure the rewrite rule in the .htaccess file on the root directory, not in WordPress:

RewriteRule ^thepage(/)?$ sub-folder/index.php?page_id=12 [L]

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.