1

I'm currently working on ironing out some little problems with my website and prep it for SEO a little bit. I followed Google's SEO Optimization guide and found this quote:

Consider what happens when a user removes part of your URL - Some users might navigate your site in odd ways, and you should anticipate this. For example, instead of using the breadcrumb links on the page, a user might drop off a part of the URL in the hopes of finding more general content. He or she might be visiting http:// www.brandonsbaseballcards.com/news/010/upcoming-baseballcard-shows.htm, but then enter http://www.brandonsbaseballcards.com/news/010/ into the browser's address bar, believing that this will show all news from 010. Is your site prepared to show content in this situation...?

Well, currently my site is not prepared for this situation and would direct the user to a directory or a 404 page.

I searched on the web for a little bit and found this and this link which seem to go into the right direction but I wasn't quite sure. Ideally, I would like to try this out on localhost (XAMPP) before I upload the page.

So my question would be, how would I redirect (through htaccess) a user who puts in, say, http://www.example.com/baseballcards to http://www.example/baseballcards/all.html?

Thank you very much!

Community
  • 1
  • 1
rf2012
  • 233
  • 2
  • 7
  • 13

1 Answers1

1

Enable mod_rewrite and .htaccess through httpd.conf and then put this code in your .htaccess under DOCUMENT_ROOT directory:

Options +FollowSymLinks -MultiViews
# Turn mod_rewrite on
RewriteEngine On
RewriteBase /

RewriteRule ^(baseballcards)/?$ /$1/all.html [L,NC]

Above rule will internally forward /baseballcards to /baseballcards/all.html but won't change the URL in the browser (external redirect). If you want external redirection then use following rule:

RewriteRule ^(baseballcards)/?$ /$1/all.html [R=301,L,NC]
anubhava
  • 761,203
  • 64
  • 569
  • 643