1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

modrewrite and rewritecond

Discussion in 'Site & Server Administration' started by jperezmt, May 16, 2008.

  1. #1
    I'm trying to make friendly urls for my site but I'm having some issues. I looked at a bunch of tutorials for mod rewrite and .htaccess and I got far enough where it works but I'm having trouble getting rid of the old links.

    The address is www.thesite.com/blog.php?id=34

    I got the mod rewrite to display it as

    www.thesite.com/blog34/PHP/TITLEOFBLOG.htm

    Options +FollowSymLinks
    RewriteEngine On
    RewriteRule ^blog([0-9A-Za-z]+)/([0-9A-Za-z]+)/([0-9A-Za-z]+).htm$  blog.php?id=$1&category=$2&title=$3 [L]
    
    Code (markup):
    But I'm trying to eleminate duplicate content and get redirect the blog.php?id=34 to the new URL

    Here is my code

    RewriteCond %{QUERY_STRING} ^id=([0-9]+)
    RewriteRule ^blog\.php /blog%1/%2/%3.htm? [R=301,L]
    Code (markup):
    So the %2 and %3 don't exist in the redirect so I'm getting
    www.thesite.com/blog34//.htm

    How can I redirect the old URLS with only the ID to the new ones that list the category and title?

    Also, is it possible to just get rid of the ID number so I can have the same content display with just text?

    THANKS!!!!!

    EDIT:
    When I type www.thesite.com/blog34/PHP/TITLEOFBLOG.htm I can get to the correct blog post BUT if I type www.thesite.com/blog34/anything that comes to mind/it doesn't matter what I type here.htm I still get the same blog, how do I stop that from happening so that the page is unique?
     
    jperezmt, May 16, 2008 IP