Jump to content

url - hyphens instead of spaces??


eugene2009

Recommended Posts

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..

Link to comment
https://forums.phpfreaks.com/topic/187995-url-hyphens-instead-of-spaces/
Share on other sites

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

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.