If you can load your CSV file content then This is the way to import Bulk URL Rewrite:
Add below Code into script than run it.
// MAGENTO START
include('../../../app/bootstrap.php');
use Magento\Framework\App\Bootstrap;
use Magento\Framework\App\Config\ScopeConfigInterface;
use Magento\Store\Model\StoreManagerInterface;
use Magento\Framework\Exception\LocalizedException;
use Magento\UrlRewrite\Model\UrlFinderInterface;
use Magento\UrlRewrite\Service\V1\Data\UrlRewrite;
$bootstrap = Bootstrap::create(BP, $_SERVER);
$objectManager = $bootstrap->getObjectManager();
$state = $objectManager->get('Magento\Framework\App\State');
$state->setAreaCode('frontend');
$scopeConfig = $objectManager->create('Magento\Framework\App\Config\ScopeConfigInterface');
$_storeManager = $objectManager->create('Magento\Store\Model\StoreManagerInterface');
$dataProcessor = $objectManager->create('Magento\Framework\Reflection\DataObjectProcessor');
$storeId = $_storeManager->getDefaultStoreView()->getStoreId();
foreach($data as $key => $rec)
{
$urlRewrite = $objectManager->create(\Magento\UrlRewrite\Model\UrlRewrite::class);
$urlRewrite->load(0);
$model = $urlRewrite;
$product['entity_type'] = $rec['entity_type'];
$product['request_path'] = $rec['request_path'];
$product['target_path'] = $rec['target_path'];
$product['redirect_type'] = $rec['redirect_type'];
$product['store_id'] = $rec['store_id'];
$objectManager->get(\Magento\UrlRewrite\Helper\UrlRewrite::class)->validateRequestPath($product['request_path']);
$model->setEntityType($product['entity_type'])
->setRequestPath($product['request_path'])
->setTargetPath($product['target_path'])
->setRedirectType($product['redirect_type'])
->setStoreId($product['store_id'])
->setDescription("Imported Urls");
$model->save();
}
echo "Successfully Imported!";
$data is the data from your csv or file. which should have same name column as above imported.
entity_id is not required is you choose entity_type "custom"
Set appropriate path to include bootstrap for "include('../../../app/bootstrap.php');", I have added my script in "pub/script/vendor", So I have applied path like this.