Sangha-08 Posted October 11, 2008 Share Posted October 11, 2008 Hi guys, I'm just having a little trouble with my new script. <?php $_GET print['v']; ?> so, when i go to my website and write on the url http://www.mywebsite.com/play.php?v=Name of the video but its gets "encrypted" to http://www.mywebsite.com/play.php?name%20of%20the%20video and that kinda messes up all my urls, and is really bad for SEO is there a way to change the "%20" to "-" so that the url looks something like http://www.mywebsite.com/play.php?v=Name-of-the-video Thanks for all you help, much appreciated. Link to comment https://forums.phpfreaks.com/topic/127951-putting-instead-of-20/ Share on other sites More sharing options...
Sangha-08 Posted October 11, 2008 Author Share Posted October 11, 2008 ..any1? Link to comment https://forums.phpfreaks.com/topic/127951-putting-instead-of-20/#findComment-662570 Share on other sites More sharing options...
ratcateme Posted October 11, 2008 Share Posted October 11, 2008 you need to do it on the page that has the link it something like this <a herf="play?v=<?php echo str_replace(" ","-",$name);?>"><?php echo $name;?></a> Scott. Link to comment https://forums.phpfreaks.com/topic/127951-putting-instead-of-20/#findComment-662571 Share on other sites More sharing options...
bothwell Posted October 11, 2008 Share Posted October 11, 2008 The %20 is just the standard encoding for spaces in URLs. I use a preg_replace to change any non-alphanumeric characters when I insert to the database to generate a slug: $slug = preg_replace('/[^a-z0-9]/i', '-', $name); You only want to strip one thing, though, so you could try an str_replace instead: http://uk.php.net/str_replace Link to comment https://forums.phpfreaks.com/topic/127951-putting-instead-of-20/#findComment-662572 Share on other sites More sharing options...
Sangha-08 Posted October 11, 2008 Author Share Posted October 11, 2008 Its still not working for some reason... http://www.mywebsite.com/play.php?v=This%20Is%20The%20Name%20Of%20The%20vid I tried to use both scripts but I'm still unable to get http://ww.mywebsite.com/php?v=This-Is-The-Name-Of-The-Vid Link to comment https://forums.phpfreaks.com/topic/127951-putting-instead-of-20/#findComment-662575 Share on other sites More sharing options...
Bendude14 Posted October 11, 2008 Share Posted October 11, 2008 show us how you tried to use them in your code? Link to comment https://forums.phpfreaks.com/topic/127951-putting-instead-of-20/#findComment-662577 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.