RewriteRule for URLs with spaces
Posted
by
Robert Cailliau
on Pro Webmasters
See other posts from Pro Webmasters
or by Robert Cailliau
Published on 2013-04-29T16:26:40Z
Indexed on
2013/06/29
4:29 UTC
Read the original article
Hit count: 193
mod-rewrite
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
Using
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)
© Pro Webmasters or respective owner