Support » Fixing WordPress » how can i disable short links

  • hello.
    i want to disable wordpress short links ( website.com/?p=87500 )

    i mean when someone open this link
    should be redirect to home page or say its 404 links or something like this.
    thanks

Viewing 9 replies - 1 through 9 (of 9 total)
  • Allen McNichols

    (@allenmcnichols)

    WordPress Mechanic

    You can add a code snippet to your functions.php file of your theme:

    remove_action('wp_head', 'wp_shortlink_wp_head', 10, 0);

    I would add this to the end of that file 🙂

    Make sure to make a backup copy of the file beforehand and make sure you can reach the site using ftp just in case you make a mistake.

    Thread Starter nightdark

    (@nightdark)

    dear allenmcnichols,
    i did use this code befor you saying that
    it will just remove shortlink from header in source

    i want disable short link ! make short link broken !

    Allen McNichols

    (@allenmcnichols)

    WordPress Mechanic

    The link in your example is a permalink so if you try to 404 that link or redirect it would exclude visitors from seeing your content. Is there a particular reason why you are wanting to restrict those permalinks? The code to remove shortlink would disable the shortlink variants so that they would no longer work or be indexable but those permalinks will exist for every post and page even with the use of pretty permalinks in place.

    Thread Starter nightdark

    (@nightdark)

    my post links is this : sitename.com/postid/postname

    and this is the shortlink : website.com/?p=87500

    if i make short link broken , wont be bad for my users

    there is a reason i dont want this short link and i need away to make it broken !

    maybe is there any code to redirect shortlinks to home page ?

    • This reply was modified 1 year, 9 months ago by nightdark.
    Moderator Jan Dembowski

    (@jdembowski)

    Forum Moderator and Brute Squad

    @nightdark Unless you after reporting spam, abuse or something broken in the forums, please do not use the “Report this topic” link.

    It’s not for somehow getting faster support. It only gets the attention of forum moderators looking for spam, abuse or something broken in the forums.

    Allen McNichols

    (@allenmcnichols)

    WordPress Mechanic

    I really don’t know a good way around this one without using another plugin to redirect each individual post id you have active to go to a 404 page or to the homepage. The /?p=87500 would redirect to the post/page that has the ID of 87500 by default. You could try using the plugin for Redirection ( https://wordpress.org/plugins/redirection/ ) and then setup redirects for each of those post ID’s but that seems pretty tedious to do upkeep for.

    Thread Starter nightdark

    (@nightdark)

    there is too much posts !
    i need away to redirect all pages
    maybe using htaccess redirect code…!

    Thread Starter nightdark

    (@nightdark)

    it is possible to to delete this post?

    Moderator Jan Dembowski

    (@jdembowski)

    Forum Moderator and Brute Squad

    @nightdark I’m sorry, but that is only done in extreme cases.

    https://wordpress.org/support/forum-user-guide/faq/#my-post-shows-up-on-a-search-for-my-domain-will-you-delete-my-post-or-my-link

    Search engine hits are never considered extreme. The post will not be edited or deleted. There is no reason to delete this topic.

Viewing 9 replies - 1 through 9 (of 9 total)
  • The topic ‘how can i disable short links’ is closed to new replies.