Using RewriteBase

I'm trying to get nice URLs working in a multi-language environment.

The base configuration of the site is like this.

<VirtualHost *:80>
DocumentRoot /opt/www/mysite
ServerName mysite
Alias /en /opt/www/mysite-en
Alias /es /opt/www/mysite-es
</VirtualHost>

If i add Rewrite conditions in the VHost, the rewriting works for the
base site, but not for the localized sites (each of them have a urls
parsing script named url.php).


<VirtualHost *:80>
DocumentRoot /opt/www/mysite
ServerName mysite
Alias /en /opt/www/mysite-en
Alias /es /opt/www/mysite-es
RewriteEngine on
RewriteCond /opt/www/mysite/%{REQUEST_FILENAME} !-f
RewriteRule ^/(.+) /url.php
</VirtualHost>


So i've tried creating per-directory configurations:


<VirtualHost *:80>
DocumentRoot /opt/www/mysite
ServerName mysite
Alias /en /opt/www/mysite-en
Alias /es /opt/www/mysite-es
<Directory "/opt/www/mysite-en/">
AllowOverride All
</Directory>
<Directory "/opt/www/mysite-es/">
AllowOverride All
</Directory>
</VirtualHost>


And in the .htaccess files located at the root of each aliased directory:

RewriteEngine On
RewriteBase /es
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^/(.+) /url.php


i've tried several combinations as:

RewriteEngine On
RewriteBase /es
RewriteCond /opt/www/mysite-es/%{REQUEST_FILENAME} !-f
RewriteRule ^/(.+) /es/url.php


But there is no rewriting going on. The .htaccess file seems being
parsed, as if i put gibberish in it, the server returns me an Internal
Server Error.

TIA,
alex.
Hans-Peter Sauer [ Di, 16 Oktober 2007 12:18 ] [ ID #1846233 ]

Re: Using RewriteBase

"alex" <me [at] privacy.net> schreef in bericht news:ff236c$h9r$1 [at] aioe.org...
> i've tried several combinations as:
>
> RewriteEngine On
> RewriteBase /es
> RewriteCond /opt/www/mysite-es/%{REQUEST_FILENAME} !-f
> RewriteRule ^/(.+) /es/url.php
>
> But there is no rewriting going on.

In .htacces you should NOT attempt to match the leading /
Unsure about the leading path in the replacemant.

HansH
HansH [ Di, 16 Oktober 2007 12:30 ] [ ID #1846234 ]

Re: Using RewriteBase

HansH wrote:
>
> In .htacces you should NOT attempt to match the leading /
> Unsure about the leading path in the replacemant.
>

I'm not sure if i completely understood this, but either

RewriteEngine On
RewriteBase es
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^/(.+) es/url.php

or

RewriteEngine On
RewriteBase es
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^/(.+) /url.php

or

RewriteEngine On
RewriteBase es
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^/(.+) /es/url.php

give me an Internal Server Error
Hans-Peter Sauer [ Di, 16 Oktober 2007 12:37 ] [ ID #1846235 ]

Re: Using RewriteBase

I've added rewrite logs, and this is an output for http://mysite/es/test/asd


192.168.6.2 - - [16/Oct/2007:12:52:19 +0200]
[mysite/sid#81642e8][rid#8384db0/initial] (2) init rewrite engine with
requested uri /es/test/asd
192.168.6.2 - - [16/Oct/2007:12:52:19 +0200]
[mysite/sid#81642e8][rid#8384db0/initial] (1) pass through /es/test/asd


directory "test" exists, but "asd" not, so the rewrite engine should be
triggered, but it passes through.
Hans-Peter Sauer [ Di, 16 Oktober 2007 12:55 ] [ ID #1846236 ]

Re: Using RewriteBase

"alex" <me [at] privacy.net> schreef in bericht news:ff249h$jqm$1 [at] aioe.org...
>> In .htacces you should NOT attempt to match the leading /
>> Unsure about the leading path in the replacemant.
> I'm not sure if i completely understood this, but either
>
> RewriteEngine On
> RewriteBase es
> RewriteCond %{REQUEST_FILENAME} !-f
> RewriteRule ^/(.+) es/url.php
>
> give me an Internal Server Error
Drop the / at ther ule not the base
RewriteEngine On
RewriteBase /es
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.+) /es/url.php
unsure about the last line, perhaps better
RewriteRule ^(.+) url.php

HansH
HansH [ Di, 16 Oktober 2007 13:34 ] [ ID #1846237 ]
Webserver » alt.apache.configuration » Using RewriteBase

Vorheriges Thema: IHS (IBM apache) spawns way too many processes
Nächstes Thema: Cannot execute os.system command (Apache 2.2.6, XP HE, Python 2.4.4, ModPython 3.3.1)