eugene2009 Posted January 11, 2010 Share Posted January 11, 2010 i tried searching but came up with nothing.. is there a way in php that i can have all the spaces in a url replaced with hyphens? for example.. i have a car part in a database, and the url would be.. domain.com/parts/bmw m5 radiator cooling fan assembly.html i have that mod rewrite option.. but how can i make it .. domain.com/parts/bmw-m5-radiator-cooling-fan-assembly.html thanks.. Quote Link to comment https://forums.phpfreaks.com/topic/187995-url-hyphens-instead-of-spaces/ Share on other sites More sharing options...
PugJr Posted January 11, 2010 Share Posted January 11, 2010 I don't know how to do what you ask, but you can not have spaces in a URL. Quote Link to comment https://forums.phpfreaks.com/topic/187995-url-hyphens-instead-of-spaces/#findComment-992612 Share on other sites More sharing options...
cags Posted January 11, 2010 Share Posted January 11, 2010 I think the simplest answer here is probably just 'no'. PHP has a function called urlencode which you can use for turning strings that contains invalid URL characters into valid URL characters and urldecode for changing it back again, this will replace spaces with either + or %20. With mod_rewrite we really need more information to work out exactly what your trying to-do. You will need to list... - what a URL should look like in the users browser - what the filename is of the file on the actual server Quote Link to comment https://forums.phpfreaks.com/topic/187995-url-hyphens-instead-of-spaces/#findComment-992912 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.