I have WordPress pages like
https://example.com/mainpage/sub-page1
https://example.com/mainpage/sub-page2
https://example.com/mainpage/sub-page3
I have written a RewriteRule just for mainpage
RewriteRule ^mainpage$ mainpage.php [L,QSA]
also tried
RewriteCond %{REQUEST_URI} !^/mainpage/sub-page1
RewriteRule ^mainpage$ mainpage.php [L,QSA]
and
RewriteCond %{REQUEST_URI} !^/mainpage/.*$
RewriteRule ^mainpage$ mainpage.php [L,QSA]
but all the sub-pages also end up in mainpage.php instead of loading the WordPress pages.
How can I stop subpages loading mainpage.php
Any help would be appreciated.
Thank you
2
Answers
My page was https://example.com/mainpage.
RewriteRule ^mainpage$ main_page.php [L,QSA]
These changes worked for me.
Remove
$
from the pattern, and add/
and write it like thisRewriteRule ^mainpage/ mainpage.php [L,QSA]
Hopefully, this should ignore sub-pages.