I’m building a plugin for a WordPress Multisite, and each subsite needs an SEO friendly URL for various tabs that actually appear on the same page.
I have already written the system that detects the correct URL and shows the relevant tab using a query string, but I want to do it without a query string… here’s what I mean:
Currently:
http://domain.com/subsite/?tab=contact
Will load the home page of the sub-site, but containing the content of the “Contact” tab. i.e.
if (isset($_REQUEST['tab'])) {
$tab = $_REQUEST['tab'];
// Validate $tab here
get_template_part('tab', $tab);
}
What I Need:
http://domain.com/subsite/contact
To be invisibly rewritten for ALL subsites so that it ends up showing the same content, by rewriting /subsite/whatever to /subsite/?tab=whatever
Any and all help would be greatly appreciated.
I’m not going to judge your methods as others as I know nothing about your project.
To achieve what you need, use
mod_rewrite
rule like this: