You can deal with this redirect inside the controller, if you use an init method in your page:
<apex:page controller="TheController" action="{!Init}" ...
Simply check the RT provided and then redirect the user if it doesn't match the one you're interested in:
public PageReference Init()
{
// Grab the ID (or IDs in a list of the RT we don't want to redirect:
Id objRTId = [select Id from RecordType where SObjectType = 'TheObj__c' and DeveloperName = 'TheRT' limit 1][0].Id;
String chosenRT = ApexPages.CurrentPage().GetParameters().Get('RecordType');
// If no match, then redirect to the standard page by using 'nooverride=1'
if(chosenRT != objRTID)
{
// redirect to the standard new screen
String url = '/' + TheObj__c.SObjectType.GetDescribe().GetKeyPrefix() + '/e?RecordType=' + chosenRT + '&nooverride=1';
return new ApexPages.PageReference(url).SetRedirect(true);
}
return null;
}
Note that instead of using override=0
or sfdc.override=0
as you might expect from looking at the URL of the Visualforce page, the parameter to use is nooverride
which must be set to 1
.