PDA

View Full Version : Unwanted characters in a URL


dartho
06-30-2008, 12:49 AM
Someone asked me to write a plugin which adds the threads title to URLs - for example if teh thread is call "What is your name & age?" they'd want URL's to be written as .../showthread.php?t=737&thread_title=What-is-your-name-and-age

this is pretty simple to do, but I was wondering what sort of things would need to be removed from the title to make sure the created URL is valid

I've a few such as '&' (vbulletin nicely removes the ampersand and puts this in),'?' and accented characters - what other things do we not want appearing in URL's ?

Thanks

nexialys
06-30-2008, 12:57 AM
you can simply evaluate this: https://vborg.vbsupport.ru/showthread.php?t=173738

Sema
06-30-2008, 12:57 AM
There is an idea but I am not sure about it

You can add / if the title have some of these characters and make the variable like that '$characters'

Don't ask me how because I don't know how to do it and I am not sure about it :)

dartho
06-30-2008, 01:13 AM
you can simply evaluate this: https://vborg.vbsupport.ru/showthread.php?t=173738

It's not for me - I don;t really have any use for keyword URL rewrites...

I have used URL-rewrite type SEO things in the past and the one thing I have struck is that once you start using them, ceasing to use them changes all your URLs and as such search engines have to re-index all your pages again with the new URLs. This is a problem if you want to stop the product for one reason or another, or if a product is not compatible with a later version etc...

Doing something like this will add keywords to your URL without changing it enough such that
it will become invalid should you decide to stop using it.

No need for htaccess rewrites with something like this either - justa simple plugin and some template edits.

Opserty
06-30-2008, 08:12 AM
have you looked at the PHP urlencode (http://uk3.php.net/urlencode)(), htmlentities() (http://uk3.php.net/manual/en/function.htmlentities.php) or htmlspecialchars() (http://uk3.php.net/manual/en/function.htmlspecialchars.php). function?