Non-WordPress page in subdirectory under WordPress page

As @MarkKaplun suggests, it would be preferable to store this non-WordPress file in a different area of the filesystem altogether and rewrite the URL in .htaccess. Instead of mimicking the WordPress URL in the physical directory structure – which will likely only cause you (more) problems (not least that you would need to override the WordPress front-controller).

For example, instead of saving your non-WordPress page at /city/pricing/index.php, save it at /non-wordress/city-pricing.php (for example) or /non-wordress/city/pricing/index.php (if it helps, in development, to copy the path structure – but this makes no difference to the resulting URL, since this directory structure is completely hidden from the end user).

Then in .htaccess before the WordPress front-controller (ie. before the # BEGIN WordPress section) you can do something like:

RewriteRule ^city/pricing/$ /non-wordpress/city-pricing.php [L]

This internally rewrites /city/pricing/ to /non-wordpress/city-pricing.php – this is entirely hidden from the end user.

But stress, this must go before the WordPress front-controller, otherwise you’ll simply get a 404.

Leave a Comment