If you only need the one redirect, you can definitely solve this without a plugin. However, the way to do that depends on your hosting. If you have an Apache web server with mod_rewrite enabled, you could add such a redirect to the .htaccess file created by WordPress. Example:
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteRule ^iphone-rental-sub/$ /iphone-rental/ [R=301]
</IfModule>
See: https://httpd.apache.org/docs/current/rewrite/remapping.html
For an nginx web server, you would need to add the redirect to the server configuration. See: https://ubiq.co/tech-blog/redirect-url-nginx/
Or add the following code to your child theme’s functions.php, your custom plugin or via code snippet plugin:
function custom_url_forward() {
if ( $_SERVER['REQUEST_URI'] == '/iphone-rental-sub/' ) {
wp_redirect( "/iphone-rental/" );
exit();
}
}
add_action( 'template_redirect', 'custom_url_forward' );
-
This reply was modified 2 months ago by
threadi.