Forum Moderators: phranque

Message Too Old, No Replies

Mod rewrite white space (%20) to hyphen (-)

         

sylar1980

9:57 pm on Sep 12, 2010 (gmt 0)

10+ Year Member



I have a problem, I searched for a few days including this site for a solution to my problem.

I have website and I call for pages from a database, this pages now contain white spaces converted to %20 when shown. I want them to be rewriten in .HTAcces into hyphens, for example:

www.domain.com/hello this is a page.php

to

www.domain.com/hello-this-is-a-page.php

note: not every page has the same amount of white spaces and i don't use any subfolders.

Since I am completely new to htacces, I don't know how to make these rewrite rules, or duplicate them from another site and modify them.

jdMorgan

4:28 pm on Sep 13, 2010 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



If you want to change the URL, you have two choices. Either edit the script that publishes these space-containing links on your pages and change the spaces to hyphens in the script, or (on Apache 2.x) use an output filter to edit the links on-the-fly as they are sent to the client. Once the client "sees" a URL, nothing you can do on the server side can change that URL.

Links on pages create and define URLs, and the server cannot change them.

Jim