You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@httpd.apache.org by Frank Arensmeier <fr...@nikehydraulics.se> on 2007/02/09 14:35:30 UTC
[users@httpd] Help with mod_rewrite
Hello.
I apologize if this has been asked before. Based on the requested
url, I am trying to map those urls to my file system. I have come up
with the following Rewrite rule (in my htaccess file)so far:
RewriteRule ^(se|en|us)/(.+) /$2 [E=LANG_CODE:$1]
As you can see, my site is been translated into english, american
english and swedish. Based on the env variable ['REDIRECT_LANG_CODE],
I include either English, Swedish or whatever language it might be in
the html output. A request for e.g.:
http://myserver.com/en/about/history.php will be remapped to the file
"histrory.php" in the folder "about". This is actually working as I
thought I would be. The problem is when a user requests a URL like:
http://myserver.com/en/about
Apparently, Apache does an internal redirect because it is looking
for the index.php file (which exists) in the folder "about". The
thing I do not understand is why the user is being redirected to
http://myserver.com/about??? When doing so, the environmental
variable LANG_CODE is lost. Why? How can I map those requests to my
index file without redirecting the user?
Am I making sense?
//frank
Re: [users@httpd] Help with mod_rewrite
Posted by Bob <bo...@googlemail.com>.
Frank Arensmeier wrote:
> The problem is when a user requests a URL like:
>
> http://myserver.com/en/about
>
> Apparently, Apache does an internal redirect because it is looking for
> the index.php file (which exists) in the folder "about". The thing I do
> not understand is why the user is being redirected to
> http://myserver.com/about???
I think there's an external redirect to /about/ (notice the trailing
slash). This is normal procedure done by mod_dir. Use a RewriteRule,
which fixes the trailing slash problem.
RewriteCond %{REQUEST_URI} !/$
RewriteRule !\.[a-z]{2,4}$ %{REQUEST_URI}/ [R=301,L]
RewriteRule ^(se|en|us)/(.+) /$2 [E=LANG_CODE:$1]
--
Bob
---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
" from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org