Create WordPress Page that redirects to another URL

前端 未结 9 1847
被撕碎了的回忆
被撕碎了的回忆 2021-02-01 02:40

I wanted to create a new WordPress page that is actually a link to another site. The goal is to have the page show up in a list of my pages, but actually send the web user to t

9条回答
  •  星月不相逢
    2021-02-01 03:12

    I've found that these problems are often best solved at the server layer. Do you have access to an .htaccess file where you could place a redirect rule? If so:

    RedirectPermanent /path/to/page http://uri.com
    

    This redirect will also serve a "301 Moved Permanently" response to indicate that the Flickr page (for example) is the permanent URI for the old page.

    If this is not possible, you can create a custom page template for each page in question, and add the following PHP code to the top of the page template (actually, this is all you need in the template:

    header('Location: http://uri.com, true, 301');
    

    More information about PHP headers.

提交回复
热议问题