phranque

msg:4419990 | 3:23 pm on Feb 21, 2012 (gmt 0) |
meet the RewriteCond directive and HTTP_HOST server variable: http://httpd.apache.org/docs/2.0/mod/mod_rewrite.html#rewritecond
|
Simon Giddings

msg:4419991 | 3:28 pm on Feb 21, 2012 (gmt 0) |
Hi phranque, So we meet again ! Yep, I looked at this, but have not seen how to use it in this context. Here is what I tried to do : RewriteCond %(http_host) ^en\.example\.com [nc] RewriteRule ^english-page.php$ ./mypage.php?lang=en [L] As you can probably see straight away, this doesn't work. Can you help me any further ... please ?
|
Simon Giddings

msg:4419995 | 3:38 pm on Feb 21, 2012 (gmt 0) |
Heads up ! Just found what (I think) was wrong - used normal brackets instead of curly brackets in the rewritecond directive. Is there anything else I should be changing, do you think ?
|
phranque

msg:4420021 | 4:29 pm on Feb 21, 2012 (gmt 0) |
in .htaccess i would do something like: RewriteEngine on RewriteCond %{http_host} ^en\.example\.com$ [NC] RewriteRule ^english-page.php$ mypage.php?lang=en [L] |
|
|
phranque

msg:4420037 | 4:53 pm on Feb 21, 2012 (gmt 0) |
also, depending on your configuration, you might need this: Options +FollowSymLinks
|
lucy24

msg:4420150 | 8:39 pm on Feb 21, 2012 (gmt 0) |
| Just found what (I think) was wrong - used normal brackets instead of curly brackets in the rewritecond directive. |
| Ouch! You mean in your posted example where you had something in parentheses? I'm impressed it didn't simply crash the server :) RewriteCond %{http_host} ^en\.example\.com$ [NC] RewriteRule ^english-page.php$ mypage.php?lang=en [L] |
| What happens if the user requests en.example.com/english-page.php?lang=en Dealing with requests that are supposed to work is the easy part. But if you're rewriting you also have to deal with requests that are not supposed to work. Nothing fancy, just make sure they end up with a 404 rather than a 500 or an infinite-redirect loop. "It is impossible to make things foolproof, because fools are so ### ingenious." But you need to try.
|
|