Forum Moderators: phranque

Message Too Old, No Replies

How to get rid of question marks, commas, and unwanted characters

using htaccess

         

chopin2256

7:57 am on Sep 29, 2005 (gmt 0)

10+ Year Member



I am trying to get rid of question marks, commas, exclamation points, parathesis, and any non alphabetic characters in a particular phrase in a url. This is an example of URLS I have to deal with:

http://www.example.com/wiki/index.php?title=Clarinet,-flute,-or-Trumpet?&action=edit

I want to get rid of the question marks and commas only in this phrase "Clarinet,-flute,-or-Trumpet?&action=edit" using htaccess. Any advice?

jd01

11:14 am on Sep 29, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



There is not really an easy way to do this in mod_rewrite, unless all occurances will be standardized in some way (EG a set number of unwanted characters). Usually better to use the scripting language that are creating the URL/Query Strings.

Justin

chopin2256

5:13 pm on Sep 29, 2005 (gmt 0)

10+ Year Member



So you can get rid of question marks and commas to hyperlinks using php? I though it only worked after you clicked on the link.

chopin2256

5:25 pm on Sep 29, 2005 (gmt 0)

10+ Year Member



Using something like this in php I think is what I need:

$t->mDbkeyform = preg_replace("#<a href=\"http://www.example.com/wiki/index.php\?title=([0-9]*)&amp;st=([0-9]*)\">(.+?)</a>

I am not exactly sure what to put after the title=

I think this is pretty close to the solution...I hope.

Again, this is the url I want to format:

http://www.example.com/wiki/index.php?title=Clarinet,-flute,-or-Trumpet?&action=edit

chopin2256

7:47 pm on Sep 29, 2005 (gmt 0)

10+ Year Member



Solved.

Thank you for bringing to my attention htaccess wasn't necessary. I solved it using php. I really like mediawiki, the only problem is, it doesn't have software help support!

jd01

8:44 pm on Sep 29, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Glad you got it to work...

Justin