How do I remove spaces and apostrophes from a PURL?

If someone types an apostrophe, how can we remove the apostrophe (e.g. typed O'halloran becomes Ohalloran) Also if someone types a space between first and last name can it default to a full stop? (e.g. typed John O'halloran becomes John.Ohalloran)

Removing spaces and apostrophes from personalized URLs

This is a great question. To do that you would add the following two lines of code to your .htaccess file, just BEFORE the Rewriterule.

#Remove Space
Rewriterule ^([^/]*)\ ([^/]*)$ $1.$2 [N,E=redirect:1]

#Remove Apostrophe
Rewriterule ^([^/]*)'([^/]*)$ $1$2 [N,E=redirect:1]<br>

Your entire PURL .htaccess code will look something like:


RewriteEngine on

RewriteCond %{SCRIPT_FILENAME} !([A-Za-z0-9_]+).(html?|php|asp|css|jpg|gif|shtml|htm|xhtml|txt|ico|xml)/?$ [NC]

RewriteCond %{REQUEST_FILENAME} !-d

RewriteCond %{REQUEST_FILENAME} !-f

#Remove Space
Rewriterule ^([^/]*)\ ([^/]*)$ $1.$2 [N,E=redirect:1]

#Remove Apostrophe
Rewriterule ^([^/]*)'([^/]*)$ $1$2 [N,E=redirect:1]

RewriteRule ^([A-Za-z0-9]+).([A-Za-z0-9]+)/?$$1$2&ID=123&page=1 [R,L]