URL rewriting - replacing %20 with a _.

Discussion in 'PHP' started by BarneyBeebs, Apr 10, 2010.

  1. #1
    Hi,

    I have a link sharing site set up for a few months now and I have noticed the way the URL's are rewritten aren't exactly search engine friendly, here is a example

    http://theultimatelinksharingsite.c...zuki/96 - Suzuki DR 650 Service Repair Manual

    I would like to replace the %20 with a underscore so it would read:

    http://theultimatelinksharingsite.c...zuki/96_-_Suzuki_DR_650_Service_Repair_Manual

    As I understand it the URL's are rewritten in htaccess, here is the bulk of the code:

    Options +FollowSymlinks
    RewriteEngine on
    RewriteBase /

    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_URI} ^/([0-9]+?)$
    RewriteRule ^(.+?)$ index.php?page=$1

    RewriteCond %{REQUEST_FILENAME} !-f t
    RewriteCond %{REQUEST_URI} ^/(.+?)/(.+?)/(([0-9]|[^0-9]).+?)$
    RewriteRule ^(.+?)/(.+?)/(.+?)$ viewlink.php?category=$1&sub_category=$2&link=$3 [L]

    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_URI} ^/(.+?)/(.+?)/([0-9]+?)$
    RewriteRule ^(.+?)/(.+?)/(.+?)$ index.php?category=$1&sub_category=$2&page=$3 [L]

    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_URI} ^/([^/]+)/([^/]+)$
    RewriteRule ^(.+?)/(.+?)$ index.php?category=$1&sub_category=$2 [L]

    I would be very greatful if someone could point me in the right direction.

    Thanks,
    Brian
     
    BarneyBeebs, Apr 10, 2010 IP
  2. krsix

    krsix Peon

    Messages:
    435
    Likes Received:
    11
    Best Answers:
    0
    Trophy Points:
    0
    #2
    that is up to your script to provide links and canonical tag in <head> with the proper url, not mod_rewrite.
    mod_rewrite will pass it along, YOUR script has to understand Suzuki_DR_650_Service_Repair_Manual.

    this is an issue in your PHP, not an issue in htaccess
     
    krsix, Apr 10, 2010 IP