Jump to content

Replacing whitespace with dashes in URL (SEO Friendly)


DavidGP

Recommended Posts

Ok, so I'm somewhat a novice to PHP but I know how to do this in PHP with;

 

$nospaces = str_replace('-', '', $input);

 

But I'd like to try to do this server side with regular expressions. I'm using isapi rewrite on a win2003 server with IIS.

 

I have the current URL: http://www.gamerzunite.com/content.php?showtopic=Killzone 2 Preview

 

Which gets translated to this: http://www.gamerzunite.com/Killzone 2 Preview

 

I couldn't find a way in PHP to do this without losing the ability to pull the data from MySQL without the "exact" title with spacing and all.

 

Code on the server I need to manipulate:

 

RewriteRule  ^/(~)([^/.\?]+)(?!\.php)$        /content.php?showtopic=$2 
RewriteRule  ^/([^/.\?]+)$        /content.php?showtopic=$1

 

So what would it involve changing the above code to insert dashes instead of spacing? Thanks.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.