Disable Categories, Tags and Author Pages on Your WordPress Website

Photo by Arnel Hasanovic on Unsplash

I couldn’t find any straightforward super-fast solution online so, this is mine.

It will take you:

  • 1 actual line of code
  • 1 minute

It assumes that :

  • Your WordPress website is hosted on an Apache server
  • Your Apache server supports mod_rewrite
  • You have full access to .htaccess

It will let you redirect users to the home page in case they try to access a category / tag / author page.

Step by Step

  1. Connect via FTP to your web server.
  2. Download the .htaccess file at the root of your WordPress installation (usually /www)
  3. Open the file for edition.
  4. Copy-Paste this block at the beginning of the file :

5. Save, close and upload the file to your web server.

How it works

Should you have 1 minute to dig a little bit into a short explanation, this is the right place.

  • Line 1 and 4 : Tells Apache to execute the block only if the mod_rewrite module is present.
  • Line 2 : Tells Apache to activate the Rewrite Engine. This engine can rewrite URLs on the go.
  • Line 3 : We define a rule following this common syntax :

RewriteRule patternToMatchAgainst whereToRedirect [Options]

  • ^(author|tag|category)\/.+$ : This is the pattern to match against.

If you’re not familiar with regular expressions, take a look to this article

This pattern means : If the request looks like /author/anything or /tag/anything or /category/anything then, redirect somewhere.

  • / : This is the place we redirect the user in case the pattern is matched. It is the root of your WordPress website. It means that if someone tries to navigate to a category / tag / author page, he will be redirected to the home page.

Thanks for reading

I hope this short tutorial has been helpful to you and solved this common need.

Running my own WordPress website, I prefer having almost no plugin installed and that’s why configuring Apache seemed to be the way to go.

Check out my latest tutorial :

The Easiest Tutorial on React Router v4 You’ll Ever Find  -  Build a Single-Page-Application in seconds

Feel free to reach out at david.mellul@outlook.fr

“Cappuccino in a white mug with white foam art on a wooden table” by wu yi on Unsplash
David

Fullstack Developer, Trainer & Entrepreneur.

Learning stuff, sharing knowledge and building on top of great ideas are my top priorities.

Leave a Reply

Your email address will not be published.

Share
Share