Support » Localhost Installs » How do I redirect a WordPress Page without plugins?

Viewing 1 replies (of 1 total)
  • threadi


    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]


    For an nginx web server, you would need to add the redirect to the server configuration. See:

    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/" );
    add_action( 'template_redirect', 'custom_url_forward' );
    • This reply was modified 2 months ago by threadi.
Viewing 1 replies (of 1 total)
  • You must be logged in to reply to this topic.