redirect to a page without changing the url

i have a wordpress site installed on mywebsite.com/fr/
i want the page mywebsite.com/fr/testpage/ to redirect to mywebsite.com/fr/pagewithweirdurl/ but still showing in the url mywebsite.com/fr/testpage/
i found plugins that redirect fine, but it always changes the url.
i found many htaccess codes in here that do what i want, but they do it for the entire website, i just need these specific pages to do what i want . the rest is fine.

so if someone could help me with an htaccess code and show me how to change the urls in the code for the pages i want i would really appreciate it.
if you know a plugin that does the redirection whilst keeping the url and not changing it im interested too.

Related posts

Leave a Reply

1 comment

  1. Add this to your .htaccess in your web root / directory

    RewriteEngine on
    RewriteBase /
    
    RewriteCond %{REQUEST_FILENAME} !-d # not a dir
    RewriteCond %{REQUEST_FILENAME} !-f # not a file
    RewriteRule ^fr/testpage/?$ /fr/pagewithweirdurl/ [NC,L]
    

    The key here is not use the [R] flag for the rewrite rule which causes an external redirection and changes the URL in the browser’s address bar. This assumes that /fr/testpage/ doesn’t exist physically. If you’re trying to redirect an existing file/directory remove the two RewriteConditions.