Forum Moderators: phranque

Message Too Old, No Replies

.htaccess to replace characters in URLs

how to change - to +

         

victories

1:47 am on Jul 3, 2009 (gmt 0)

10+ Year Member



Hi,

I use this rule and I need some little help

RewriteCond %{HTTP_HOST} !^www\.website\.com$ [NC]
RewriteCond %{HTTP_HOST} ^(www\.)?([^\.]+)\.website\.com$ [NC]
RewriteRule ^$ [website.com...] [L]

and result
hello-world.website.com to www.website.com/index.php?x=arama&kelime=hello-world

but I need replace (-) to (+)

hello-world.website.com to www.website.com/index.php?x=arama&kelime=hello+world

how to change my rule.

sorry for bad english

g1smd

2:26 am on Jul 3, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Before getting into that, be aware that as coded you have a 302 redirect.

Were you instead looking for a 301 redirect or for an internal rewrite here?

victories

2:42 am on Jul 3, 2009 (gmt 0)

10+ Year Member



I have a video website

all the singers, I would like to subdomain. e.g.

michael-jackson.mywebsite.com
elvis-presley.mywebsite.com

When using this code

RewriteCond %{HTTP_HOST} !^www\.website\.com$ [NC]
RewriteCond %{HTTP_HOST} ^(www\.)?([^\.]+)\.website\.com$ [NC]
RewriteRule ^$ [website.com...] [L]

between words - I want to replace +

I want to 301 redirect

jdMorgan

3:21 am on Jul 3, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Redirecting would be a mistake, because it would expose the dynamic path to the client as a URL... Not good.

I'd recommend an internal rewrite.

I'd also suggest changing the "-" characters to "+" characters using preg_replace within the index.php script itself; Replacing characters using mod-rewrite is *terribly* inefficient, especially when the number of characters to be replaced can vary.

Finally, pick either <artist>.example.com or www.<artist>.example.com as the canonical domain and redirect the non-canonical domain to the selected canonical one. Do not allow both to resolve directly to content. See the "duplicate content" threads in the "Google Hot Topics FAQ" section of our Google News forum for more information.

Jim

victories

3:37 am on Jul 3, 2009 (gmt 0)

10+ Year Member



OK. I got it, thank you very much for your help.