Forum Moderators: phranque

Message Too Old, No Replies

Mod rewrite whitespace newbie problem

mod rewrite question

         

martiniman

5:02 am on Jul 15, 2004 (gmt 0)

10+ Year Member



Hi all, just registered here and already got a Q.

I have a mod rewrite problem. Please look at my htaccess below:

RewriteEngine on
RewriteRule ^$ country.php?country=bla bla?%{QUERY_STRING}
RewriteRule ^bla bla/$ country.php?country=bla bla%{QUERY_STRING}

what i basically want with above url is that my website with country name "bla bla" should come up in the browser address bar www.website.com/bla bla/

Somehow this does not work when there is a whitespace in the country name which I want to use. Is there somehow a solution to this? I am totally newbie in this stuff so any help would be great.

p.s. of course I have more countries which i want to list with rewriting url's. Is there a possibility to use a single command that bypasses whitespaces in URL's?

jdMorgan

5:35 am on Jul 15, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



martiniman,

Welcome to WebmasterWorld [webmasterworld.com]!

Please save yourself a lot of headaches now and in the future... Don't use whitespace in URLs, that's a "Windows filesystem thing", and causes all kinds of problems with non-MS applications. Use hyphens (preferred for search engine purposes) or underscores if you must, but not spaces. If you're really adamant about using spaces, you'll have to unicode them as %20.

Jim

martiniman

5:53 am on Jul 15, 2004 (gmt 0)

10+ Year Member



Hi, well if i try to use mod rewrite like this:

RewriteEngine on
RewriteRule ^$ country.php?country=bla%20bla?%{QUERY_STRING}
RewriteRule ^bla%20bla/$ country.php?country=bla%20bla%{QUERY_STRING}

it does not work. How can i get it to work then?

jdMorgan

6:17 am on Jul 15, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



See the [NE] (noescape) flag for RewriteRule. Also, you can use the [QSA] flag to append new query parameters to the existing query string. Note that only one "?" should be present in the query; the other parameters should be delimited using "&".

Jim

martiniman

6:44 am on Jul 15, 2004 (gmt 0)

10+ Year Member



Hi, this is all unfamiliar to me. Can you give me an example how to display e.g. a file called:

hello world.html

using mod_rewrite displaying:

www.website.com/hello-world/

jdMorgan

3:48 pm on Jul 15, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I don't use spaces, and I've never tried or tested this, so it may not work... Like I said, spaces cause problems. Try something like this:

RewriteRule ^$ country.php?country=bla%20bla [QSA,NE,L]

Jim