Forum Moderators: phranque

Message Too Old, No Replies

mod rewrite an apostrophe?

mod_rewrite an apostrophe?

         

Tim_Mousel

9:07 am on Jan 30, 2009 (gmt 0)

10+ Year Member



RewriteCond %{QUERY_STRING} (.*)$
RewriteRule item_([0-9]+)(\.[a-z]{3,4})?(.*)$index.php?_a=viewtiem&item_id=$1&%1 [NC]

How would I write the above to replace an apostrophe with a space? For example, change women's to womens?

Thanks in advance.

Tim

jdMorgan

4:35 pm on Jan 30, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Do you want to change the URL, or to change the filepath? These are two entirely different things.

Also, be aware that you could code that rule much more efficiently as one line:


RewriteRule item_([0-9]+)(\.[a-z]{3,4})? index.php?_a=viewtiem&item_id=$1 [NC,[b]QSA,L[/b]]

[QSA] tells mod_rewrite to retain the original query string, appending new parameters instead of replacing the original ones. Removing the trailing "(.*)$" on your pattern saves a bit of CPU time, and does not change the function of the rule at all.

Jim