imperium2335 Posted May 22, 2011 Share Posted May 22, 2011 Hi, I currently have this rule: RewriteRule stuff-i-(.*)-n-(.*)\.html$ stuff.php?i=$1&n=$2 Which is working great, but 'n' is a title from a database which often has spaces and comes out with %20s in. How can this line be adjusted to replace all %20 with - (dashes) ? Link to comment https://forums.phpfreaks.com/topic/237131-replace-spaces-submatch/ Share on other sites More sharing options...
wildteen88 Posted May 22, 2011 Share Posted May 22, 2011 You should be replacing the spaces in PHP when outputting your links. Not mod_rewrite. Link to comment https://forums.phpfreaks.com/topic/237131-replace-spaces-submatch/#findComment-1218752 Share on other sites More sharing options...
imperium2335 Posted May 22, 2011 Author Share Posted May 22, 2011 Hi, I can't do that because the other -s will be replaced when I take them out. So 'stuff-i-14-n-Wedding%20motorbike.html' > stuff-i-14-n-Wedding-motorbike.html > stuff i 14 n Wedding motorbike.html Which won't work Link to comment https://forums.phpfreaks.com/topic/237131-replace-spaces-submatch/#findComment-1218757 Share on other sites More sharing options...
wildteen88 Posted May 22, 2011 Share Posted May 22, 2011 Then replace the spaces with an underscore (_) instead? Link to comment https://forums.phpfreaks.com/topic/237131-replace-spaces-submatch/#findComment-1218775 Share on other sites More sharing options...
imperium2335 Posted May 22, 2011 Author Share Posted May 22, 2011 Hi, _ are less seo friendly than - Link to comment https://forums.phpfreaks.com/topic/237131-replace-spaces-submatch/#findComment-1218792 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.