Quantcast
Channel: Lecciones Prácticas
Viewing all articles
Browse latest Browse all 33

Redirect wordpress main page to category [SOLVED]

$
0
0

This is a usual question in forums: How to redirect the wordpress main page to a category post page?

This is: when http://yoursite.com loads, you want to be redirected to http://yoursite.com/category/mycategory.

To achieve this, you can do it several ways.

Redirect wordpress main page to category using .htaccess file

Edit your .htaccess file (in your WP root folder) and replace these lines:

# BEGIN WordPress

RewriteEngine On
RewriteBase /

With these ones:

# BEGIN WordPress

RewriteEngine On
RewriteBase /

#REDIRECT HOME PAGE TO CATEGORY 'MYCATEGORY'
RewriteRule ^$ /category/mycategory [R=301,L]

Redirect wordpress main page to category in your theme

edit your theme’s index.php and insert these lines at the begining of the file:

<!-- redirect to category 'mycategory' -->
<?php
if(is_home()){
echo '<meta http-equiv="refresh" content="0; url=http://yoursite.com/category/mycategory">';
}
?>
<!-- /redirect -->

Done! :)

PS:
If you want to REMOVE the /category/ from the URL’s so that your categories won’t load in /category/mycategory but in /mycategory instead, read this post ;)


Viewing all articles
Browse latest Browse all 33

Trending Articles