URL rewrite mod

Discussion in 'Programming' started by SEOTeam, Aug 25, 2006.

  1. #1
    URL rewrite modifications are one of the best ways to change a dynamic site query string into a static looking URL that is easily crawlable by the search engines.

    I am curious if anyone has some experience doing this with random scripts.

    I have a ton of php scripts installed on my sites and I can go ahead and pay someone to build me this script but if someone knows of a good one online, free or for sale I am interested.

    Thanks
     
    SEOTeam, Aug 25, 2006 IP
  2. drewbe121212

    drewbe121212 Well-Known Member

    Messages:
    733
    Likes Received:
    20
    Best Answers:
    0
    Trophy Points:
    125
    #2
    .htaccess is my best friend now :)

    It really isn't that hard, just the regular expression nitty gritty.

    Examples:

    RewriteEngine on

    # FORCE WWW IN URL (my favorite one)
    RewriteCond %{HTTP_HOST} !^www\.mysite\.com [NC]
    RewriteRule ^(.*)$ http://www.mysite.com/$1 [R=301,L]
    # END FORCE WWW IN URL

    # change all php files to .do files
    # makes index.do actually refer to index.php
    rewriteRule ^([_0-9a-zA-Z-]*)\.do$ /$1.php

    # User Home Pages starting with a ~
    # visting /~myusername actually changes to
    # /view_user.php?username=myusername
    RewriteRule ^~([_0-9a-zA-Z-]+)/?$ /view_user.php?username=$1

    # Directories actually refering to category of something
    #/cat-food/ changes to
    # /directory.php?category=cat-food
    RewriteRule ^([_a-zA-Z0-9-]+)/?$ /directory.php?category=$1

    Have fun :)
     
    drewbe121212, Aug 25, 2006 IP
  3. SEOTeam

    SEOTeam Peon

    Messages:
    236
    Likes Received:
    7
    Best Answers:
    0
    Trophy Points:
    0
    #3
    so could I paste that code in every single php site I am running and it will just start working?
     
    SEOTeam, Aug 25, 2006 IP
  4. Mong

    Mong ↓↘→ horsePower

    Messages:
    4,789
    Likes Received:
    734
    Best Answers:
    0
    Trophy Points:
    235
    #4
    Mong, Aug 25, 2006 IP
  5. drewbe121212

    drewbe121212 Well-Known Member

    Messages:
    733
    Likes Received:
    20
    Best Answers:
    0
    Trophy Points:
    125
    #5
    Yeah except change the relevant parts. IE site.com to yourdomain.com
     
    drewbe121212, Aug 26, 2006 IP
  6. SEOTeam

    SEOTeam Peon

    Messages:
    236
    Likes Received:
    7
    Best Answers:
    0
    Trophy Points:
    0
    #6
    Thanks guys!!
     
    SEOTeam, Aug 27, 2006 IP