Make URL alias in Wordpress (or .htaccess)

12,100

Solution 1

<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteRule ^alias$ category/post [R=301,L]
</IfModule>

Solution 2

I realize this is a bit of an old post, and already has an accepted answer, but for those of us not wanting to (or unable to) play with the .htaccess file, it should be noted that there are several viable plugins in this space.

I've used https://wordpress.org/plugins/redirection/ which has 800,000+ installs. There's also https://wordpress.org/plugins/simple-301-redirects/ with 200,000+ installs as well as several others with smaller install bases available at https://wordpress.org/plugins/search/redirect/.

Share:
12,100
Jack Wild
Author by

Jack Wild

Updated on June 25, 2022

Comments

  • Jack Wild
    Jack Wild over 1 year

    I have a site running on Wordpress, and I want to create one custom short-url.

    If a page URL is www.mysite.com/category/post I want the user to be able to visit www.mysite.com/alias

    If there is a 'Wordpress-y' way of doing things, that would be preferable, but I am also able to do it by modifying the .htaccess file.

    Thanks

  • raider33
    raider33 over 7 years
    Might be worth noting that changes are to .htaccess file, since question asks whether this file should be modified or not.
  • Tony
    Tony about 4 years
    Caution about editing Rewrite rules in the .htaccess file: certain administrative actions can restore-to-default the top "wordpress part" of the .htaccess file, thereby eliminating any changes that you've made to this section. For example, sometimes a plugin update can restore the top of the .htaccess file to its default. Be careful how you edit the .htaccess file or consider a plugin.