Possible Duplicate:
Apache rewrite based on subdomain
Is it possible to rewrite a URL like this?
www.foo.website.com/some-page
to
www.website.com/some-page?var=foo
I’m asking about a rewrite (I think that’s what it’s called) and not a redirect. i.e. I want the first URL to stay in the address bar, but for the server to “get” the second URL.
I’ve never understood how to do URL rewrites and so far my pathetic attempts to get this working have failed miserably 🙂
I should add that this .htaccess file is also being used by WordPress and has the following code:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /~kbj/
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /~kbj/index.php [L]
</IfModule>
Any help or advice would be very much appreciated!
What I’ll explain is for multilanguage websites, but you can very easily apply this to what you’re asking: rename “
LANGUAGE” to “var” (smile).Here’s what you may want to do, to be able to handle in the future many sub languages.
Check your host: if it contains a “known language”, add it in a global variable (= environment variable from Apache’s point of view) then at the end, if the “language” variable is not set, set is as the default language. And finally, add it as a parameter.
(note: please, please… use proper indentation).