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.

URL Rewriting

Discussion in 'Site & Server Administration' started by johneva, Jun 8, 2009.

  1. #1
    Hi

    I could do with a little help I am trying to figure out how to do URL Rewriting I used one of them tools about but with no luck, could do with some pointers on where its wrong.

    Current URL example

    http://www.ors-recycle.com/used_furniture.php?sec=cat&cat=48&category=Boardroom

    What I would like it to be like example

    http://www.ors-recycle.com/used_furniture/sec/cat/cat/48/category/Boardroom/

    Current HTAccess file

    Options -Indexes
    
    <Files ~ "^_.*\.php$">
    	Order Allow,Deny
    	Deny from all
    </Files>
    
    
    Options +FollowSymLinks
    RewriteEngine On
    RewriteCond %{HTTP_HOST} ^ors-recycle\.com$ [NC]
    RewriteRule ^(.*)$ http://www.ors-recycle.com/$1 [R=301,NC]
    RewriteRule used_furniture/sec/(.*)/cat/(.*)/category/(.*)/ used_furniture.php?sec=$1&cat=$2&category=$3 [R=301,L]
    
    
    
    redirect 301 /new_canteen_tables.asp http://www.ors-recycle.com/new_furniture.php?category=Canteen+Tables&sec=cat&cat=46
    Code (markup):
    Cheers
     
    johneva, Jun 8, 2009 IP
  2. Whackahost.com

    Whackahost.com Member

    Messages:
    51
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    43
    #2
    Hehe use wordpress. Solve all your problems!
     
    Whackahost.com, Jun 8, 2009 IP
  3. johneva

    johneva Well-Known Member

    Messages:
    1,480
    Likes Received:
    46
    Best Answers:
    1
    Trophy Points:
    170
    #3
    What???

    How does Wordpress solve all my problems in this situation?

    Did you even bother to look at the site or problem?
     
    johneva, Jun 8, 2009 IP
  4. pcknowhow.com

    pcknowhow.com Peon

    Messages:
    47
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #4
    Hi,

    Try this. It should rewrite the URLs to this format:
    http://www.ors-recycle.com/used-furniture/Boardroom-48

    You can modify this to add sec, cat, category, etc - if you prefer.

    Options +FollowSymLinks
    RewriteEngine on
    RewriteCond %{ENV:REDIRECT_STATUS} ^$
    RewriteCond %{QUERY_STRING} sec=cat&cat=([0-9]+)&category=(.+)
    RewriteRule ^used_furniture\.php$ /used-furniture/%2-%1? [R=301,L]
    RewriteRule ^used-furniture/(.+)-([0-9]+)$ /used_furniture.php?category=$1&sec=cat&cat=$2 [L]
    Code (markup):
     
    pcknowhow.com, Jun 8, 2009 IP
  5. johneva

    johneva Well-Known Member

    Messages:
    1,480
    Likes Received:
    46
    Best Answers:
    1
    Trophy Points:
    170
    #5
    Ah that works exellent when I tried it, I am just testing at the moment using a simple rewrite with no redirect now to get the pages right, as relative file paths need to be changed to absolute by the look of it as images, css and js files are not working.

    I am now thinking maybe the redirect part would be a bad idea aswell due to the menu links will still be old dynamic style and Goggle/Search Engines still may not even try and follow them. So may just go with a rewrite and alter the coding so the menu links goto the new URLs.

    Mmmm overal this has not been as easy as I had expected, ahwell once I have done it I will know what I am doing with these for next time ay.

    Again cheers for your help that was excellent
     
    johneva, Jun 9, 2009 IP
  6. pcknowhow.com

    pcknowhow.com Peon

    Messages:
    47
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #6
    No problems.

    It's worth changing the URLs throughout to the new ones. Personally, I'd also redirect the old dynamic URLs because it'll help Google reindex your site faster and transfer any existing pagerank.

    If you decide not to redirect, then duplicate content may become an issue for you, so you may want to use robots.txt to block the old URLs.
     
    pcknowhow.com, Jun 9, 2009 IP
  7. johneva

    johneva Well-Known Member

    Messages:
    1,480
    Likes Received:
    46
    Best Answers:
    1
    Trophy Points:
    170
    #7
    Ah yeah good point redirects will need to be put in place aswell after all.

    My big problem at the moment now is figuring out how I am going to go about adjusting the menu links and breadcrumbs to get it to work, my PHP skills are not very good at all and the sites coding seems a poor standard and confusing. The menu keeps changing what URL it points to after you visit one of the pages when it still points to the same page.

    http://www.ors-recycle.com/used_furniture.php?sec=cat&cat=48&category=Boardroom
    Also has once you visit a category
    http://www.ors-recycle.com/used_furniture.php?category=Boardroom&sec=cat&cat=48&page=1

    I used your code to also do the new_furniture pages too, an they also have multiple urls in the menu they change once one category has been visited for some reason. This is driving me mental at the min.

    Cheers for you help anyways helped me get a good bit in the right direction now anyways.
     
    johneva, Jun 9, 2009 IP
  8. pcknowhow.com

    pcknowhow.com Peon

    Messages:
    47
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #8
    Ahhh. I'm not sure it's something you'll get right first time. If you haven't already, it's a good practice to set-up a development version of the site so you can test it, rather than making changes live on the fly.

    I'll drop you a PM with my MSN if you get stuck - as I don't visit here all that often.
     
    pcknowhow.com, Jun 9, 2009 IP
  9. AndyParr

    AndyParr Peon

    Messages:
    15
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #9
    Rather than rewrite all of your URL's why not just make sure you have a sitemap with all of your original url's in. Google will visit and index them then. If you rewrite google may penalise you
     
    AndyParr, Jun 10, 2009 IP