Webmasters Stack Exchange is a question and answer site for pro webmasters. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

My site's pages are in multiple languages whereby each language version shares its media (images) with the other language versions. I place all versions and the media in a single directory with the same name. E.g. pages mypage-en.html, mypage-fr.html etc. will sit in directory mypage. The directory path suffices to reference a page:
h t t p : //....../mypage/
is good enough, there is no need for
h t t p : //....../mypage/mypage-en/html
A rewrite with

RewriteRule ^(.*)/([a-zA-Z0-9]+)/?$ /$1/$2/$2-en.html  

lets me use the shorter form. But what if the name mypage contains spaces (which some do) ?
I want
h t t p : //....../my page/
to lead to
h t t p : //....../my page/my page.html


RewriteRule ^(.*)/([a-zA-Z0-9|\s]+)/?$ /$1/$2/$2-en.html  

did not work.
Any hints welcome. (please do not ask me why I want to do this, nor tell me I should not use spaces in file names)

share|improve this question
You probably don't want the |\s in your matching group. A plain space [a-zA-Z0-9 ] should be fine. – Paul Schreiber Apr 29 '13 at 17:26
Thanks, yes that works! – Robert Cailliau Apr 29 '13 at 17:49
Resubmitting as answer so you can accept it. – Paul Schreiber Apr 29 '13 at 21:25

You don't want the |\s in your matching group. A plain space [a-zA-Z0-9 ] should be fine.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.