1

This is similar to multiple endpoints to same page, but the fact that I'm trying to display the home page rather than some sub-page within the site seems to be throwing things off

I have 3 URLs:

www.mysite.com/test/link1
www.mysite.com/test/link2
www.mysite.com/test/link3

I would like for requests to all 3 to display the page at www.mysite.com. Additionally, I need for the URL displayed in the browser's location bar to remain unchanged.

Currently, I'm using:

<?php
    add_action('init', 'add_my_rule');

    function add_my_rule()
    {
        add_rewrite_rule('^test\/link.*$','index.php','top');
    }
?>

Requesting any of the above URLs does display the page at www.mysite.com as expected, BUT the URL displayed in the browser's location bar also changes to www.mysite.com instead of remaining unchanged and keeping the URL of the initial request.

I'm guessing it has something to do with my .htaccess:

# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>

# END WordPress

but I'm not really sure what it could be.

4
  • Is your front page a static page or the posts page?
    – Milo
    May 31, 2017 at 0:37
  • It is a Static page.
    – Daveh0
    May 31, 2017 at 1:17
  • 3
    Then this is your answer.
    – Milo
    May 31, 2017 at 1:33
  • Worked perfectly! Thx!
    – Daveh0
    May 31, 2017 at 4:16

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.