# How to detect /category and /tag base pages?

In a theme I'm building, I have this structure for detecting what type of page something is. However, if I visit mydomain.com/category/ or mydomain.com/tag/, all I get is the "nothing found" message I have in the have_posts()'s else statement. Is there a way to detect when these links are visited and display something other than what's in the final else statement?

if(is_category()):
echo '<h1>title here</h1>';
elseif(is_tag()):
echo '<h1>title here</h1>';
elseif(is_author():
echo '<h1>title here</h1>';
elseif(is_archive()):
echo '<h1>title here</h1>';
endif;

if(have_posts()):
//the loop
else:
echo '<h1>Nothing Found</h1>';
endif;

-

global $wp_query; if ($wp_query->query_vars['pagename'] == "category")
else if ($wp_query->query_vars['pagename'] == "tag") { // this is tag base }  But this should never be done. It is basically a junk query; a 404, and will send a 404 response code, so you will need to look at sending another response code. For that reason (if you decide to use it) this code should go in header.php although it could go high in 404.php (before any output). - When the example code I posted is used, there is no actual 404 error generated. Would it be better to redirect those pages to the home page instead, and how would that be done? – Force Flow May 29 '12 at 1:35 If I put this above the htaccess block of wordpress rules, I'm able to redirect the tag and category base pages back to the homepage. RewriteCond %{HTTP_HOST} ^mydomain.com$ [OR]
RewriteCond %{HTTP_HOST} ^localhost$RewriteRule ^category/?$ "http://mydomain.com" [R=301,L]