You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@httpd.apache.org by Alain Roger <ra...@gmail.com> on 2008/09/16 19:11:57 UTC

[users@httpd] close to success with RewriteRule

Hi,

i'm closed to succeed with RewriteRule, i just have 1 last issue
when i use:
RewriteRule ^(de|en|fr)/welcome/$    /welcome/index.php?lang=$1 [L]

everything which looks like en/welcome will be rewritten
/welcome/index.php?lang=en
this works fine... i only have 1 problem. /welcome/... does not exist in the
current context.
it exists only as http://my_ip_address/myroot/welcome/

so i tried to use RewriteBase /my_ip_address/myroot/ but without success.
how can i redirect each rule to http://my_ip_address/myroot/ ?
(without hardcoding each rewriterule as following: RewriteRule
^(de|en|fr)/welcome/$
http://my_ip_address/myroot/welcome/index.php?lang=$1 [L])

thanks a lot

-- 
Alain
------------------------------------
Windows XP SP3
PostgreSQL 8.2.4 / MS SQL server 2005
Apache 2.2.4
PHP 5.2.4
C# 2005-2008

Re: [users@httpd] Re: close to success with RewriteRule

Posted by Yusuf Koer <ma...@koer.de>.
André Warnier wrote:
> Alain Roger wrote:
> [...]
>> so if i understood well, apache understands as comment only and only 
>> if the
>> line starts by "#" character at position 1.
> Not exactly, but something like that :
> - a line where the first non-blank character is a "#" will always be 
> seen as a comment.  The # does not have to be at position 1, but it 
> should only have spaces or tabs before it.
>
> That is definitely the safest way.
>
> - apart from that, as I understand it, whether a comment at the end of 
> a command will be a problem or not, depends on the type of command.  
> If it is a command that can take several parameters separated by 
> spaces, then it will be a problem, because your comment will be 
> understood as a parameter.
>
> Anyone with a more rigorous answer ?
>
>
> ---------------------------------------------------------------------
> 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
>
Thank you very much Andre
Yusuf

---------------------------------------------------------------------
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


Re: [users@httpd] Re: close to success with RewriteRule

Posted by Eric Covener <co...@gmail.com>.
On Thu, Sep 18, 2008 at 9:17 AM, André Warnier <aw...@ice-sa.com> wrote:
> Alain Roger wrote:
> [...]
>>
>> so if i understood well, apache understands as comment only and only if
>> the
>> line starts by "#" character at position 1.

> Anyone with a more rigorous answer ?

http://httpd.apache.org/docs/2.2/configuring.html#syntax isn't
bulletproof wrt to comments and leading whitespace (although I've
never seen a problem there)

Directives in the configuration files are case-insensitive, but
arguments to directives are often case sensitive. Lines that begin
with the hash character "#" are considered comments, and are ignored.
Comments may not be included on a line after a configuration
directive. Blank lines and white space occurring before a directive
are ignored, so you may indent directives for clarity.



-- 
Eric Covener
covener@gmail.com

---------------------------------------------------------------------
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


Re: [users@httpd] Re: close to success with RewriteRule

Posted by André Warnier <aw...@ice-sa.com>.
Alain Roger wrote:
[...]
> so if i understood well, apache understands as comment only and only if the
> line starts by "#" character at position 1.
Not exactly, but something like that :
- a line where the first non-blank character is a "#" will always be 
seen as a comment.  The # does not have to be at position 1, but it 
should only have spaces or tabs before it.

That is definitely the safest way.

- apart from that, as I understand it, whether a comment at the end of a 
command will be a problem or not, depends on the type of command.  If it 
is a command that can take several parameters separated by spaces, then 
it will be a problem, because your comment will be understood as a 
parameter.

Anyone with a more rigorous answer ?


---------------------------------------------------------------------
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


[users@httpd] Re: close to success with RewriteRule

Posted by Alain Roger <ra...@gmail.com>.
Ok, so i finally found the mistake ...
at work it worked because i did not add the comment (#every rewrite rule are
based on /se_internet virtual folder so on L:\Webserver\se\internet\
physical folder
) after: RewriteBase /se_internet
when the comment is removed from the line it works great :-)
so if i understood well, apache understands as comment only and only if the
line starts by "#" character at position 1.
On Wed, Sep 17, 2008 at 7:38 PM, Alain Roger <ra...@gmail.com> wrote:

> so here is what works perfectly at work but not at home.
> at home i get error message:
>
>> Internal Server Error
>>
>> The server encountered an internal error or misconfiguration and was
>> unable to complete your request.
>>
>> Please contact the server administrator, admin@noemail.com and inform
>> them of the time the error occurred, and anything you might have done that
>> may have caused the error.
>>
>> More information about this error may be available in the server error
>> log.
>>
>
> where could be the problem ?
>
>
> local .htaccess file:
>
> Options +FollowSymlinks
>> RewriteEngine on
>>
>> # allow to rewrite the base of RewriteRule
>> RewriteBase /se_internet    #every rewrite rule are based on /se_internet
>> virtual folder so on L:\Webserver\se\internet\ physical folder
>>
>> RewriteRule ^(de|en|fr)/welcome/$    welcome/index.php?lang=$1 [L]
>>
>
>
> and my httpd.conf file:
>
> Alias /se_internet/ "L:/Webserver/se/internet/"
>> <Directory "L:/Webserver/se/internet/">
>>     #Options Indexes MultiViews
>>     Options Indexes FollowSymLinks
>>     AllowOverride All
>>     Order allow,deny
>>     Allow from all
>> </Directory>
>>
>
> thanks a lot,
>
> Al.
>
>
> On Wed, Sep 17, 2008 at 10:41 AM, Alain Roger <ra...@gmail.com> wrote:
>
>>  I still no have been successful to make it works.
>> any idea ?
>>
>>
>>
>> ---------- Forwarded message ----------
>> From: Alain Roger <ra...@gmail.com>
>> Date: Tue, Sep 16, 2008 at 7:32 PM
>> Subject: Re: [users@httpd] close to success with RewriteRule
>> To: users@httpd.apache.org
>>
>>
>> this is what i have in my .htaccess file and it seems to be ok according
>> to log:
>> #.htaccess file
>> Options +FollowSymlinks
>> RewriteEngine on
>> RewriteRule ^(de|en|fr)/welcome/$    welcome/index.php?lang=$1 [L]
>>
>> and in the log:
>> init rewrite engine with requested uri /se_internet/en/welcome/
>> pass through /se_internet/en/welcome/
>> [perdir L:/Webserver/se/internet/] add path info postfix:
>> L:/Webserver/se/internet/en -> L:/Webserver/se/internet/en/welcome/
>> [perdir L:/Webserver/se/internet/] strip per-dir prefix:
>> L:/Webserver/se/internet/en/welcome/ -> en/welcome/
>> [perdir L:/Webserver/se/internet/] applying pattern
>> '^(de|en|fr)/welcome/$' to uri 'en/welcome/'
>> [perdir L:/Webserver/se/internet/] rewrite 'en/welcome/' ->
>> 'welcome/index.php?lang=en'
>> split uri=welcome/index.php?lang=en -> uri=welcome/index.php, args=lang=en
>> [perdir L:/Webserver/se/internet/] add per-dir prefix: welcome/index.php
>> -> L:/Webserver/se/internet/welcome/index.php
>> [perdir L:/Webserver/se/internet/] internal redirect with
>> L:/Webserver/se/internet/welcome/index.php [INTERNAL REDIRECT]
>> init rewrite engine with requested uri
>> L:/Webserver/se/internet/welcome/index.php
>> pass through L:/Webserver/se/internet/welcome/index.php
>>
>>
>> however i get error message:
>> Bad Request
>> Your browser sent a request that this server could not understand.
>>
>> my welcome/index.php really and physically exists inside the folder
>> "L:/Webserver/se/internet/"
>> so what am i doing wrong ?
>> :-(
>>
>> thx.
>>
>
>
>
> --
> Alain
> ------------------------------------
> Windows XP SP3
> PostgreSQL 8.2.4 / MS SQL server 2005
> Apache 2.2.4
> PHP 5.2.4
> C# 2005-2008
>



-- 
Alain
------------------------------------
Windows XP SP3
PostgreSQL 8.2.4 / MS SQL server 2005
Apache 2.2.4
PHP 5.2.4
C# 2005-2008

Re: [users@httpd] Re: close to success with RewriteRule

Posted by Eric Covener <co...@gmail.com>.
On Wed, Sep 17, 2008 at 1:38 PM, Alain Roger <ra...@gmail.com> wrote:
> so here is what works perfectly at work but not at home.
> at home i get error message:
>>
>> Internal Server Error
>>
>> The server encountered an internal error or misconfiguration and was
>> unable to complete your request.
>>

What does your error log say?

-- 
Eric Covener
covener@gmail.com

---------------------------------------------------------------------
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


[users@httpd] Re: close to success with RewriteRule

Posted by Alain Roger <ra...@gmail.com>.
so here is what works perfectly at work but not at home.
at home i get error message:

> Internal Server Error
>
> The server encountered an internal error or misconfiguration and was unable
> to complete your request.
>
> Please contact the server administrator, admin@noemail.com and inform them
> of the time the error occurred, and anything you might have done that may
> have caused the error.
>
> More information about this error may be available in the server error log.
>

where could be the problem ?


local .htaccess file:

Options +FollowSymlinks
> RewriteEngine on
>
> # allow to rewrite the base of RewriteRule
> RewriteBase /se_internet    #every rewrite rule are based on /se_internet
> virtual folder so on L:\Webserver\se\internet\ physical folder
>
> RewriteRule ^(de|en|fr)/welcome/$    welcome/index.php?lang=$1 [L]
>


and my httpd.conf file:

Alias /se_internet/ "L:/Webserver/se/internet/"
> <Directory "L:/Webserver/se/internet/">
>     #Options Indexes MultiViews
>     Options Indexes FollowSymLinks
>     AllowOverride All
>     Order allow,deny
>     Allow from all
> </Directory>
>

thanks a lot,

Al.

On Wed, Sep 17, 2008 at 10:41 AM, Alain Roger <ra...@gmail.com> wrote:

> I still no have been successful to make it works.
> any idea ?
>
>
>
> ---------- Forwarded message ----------
> From: Alain Roger <ra...@gmail.com>
> Date: Tue, Sep 16, 2008 at 7:32 PM
> Subject: Re: [users@httpd] close to success with RewriteRule
> To: users@httpd.apache.org
>
>
> this is what i have in my .htaccess file and it seems to be ok according to
> log:
> #.htaccess file
> Options +FollowSymlinks
> RewriteEngine on
> RewriteRule ^(de|en|fr)/welcome/$    welcome/index.php?lang=$1 [L]
>
> and in the log:
> init rewrite engine with requested uri /se_internet/en/welcome/
> pass through /se_internet/en/welcome/
> [perdir L:/Webserver/se/internet/] add path info postfix:
> L:/Webserver/se/internet/en -> L:/Webserver/se/internet/en/welcome/
> [perdir L:/Webserver/se/internet/] strip per-dir prefix:
> L:/Webserver/se/internet/en/welcome/ -> en/welcome/
> [perdir L:/Webserver/se/internet/] applying pattern '^(de|en|fr)/welcome/$'
> to uri 'en/welcome/'
> [perdir L:/Webserver/se/internet/] rewrite 'en/welcome/' ->
> 'welcome/index.php?lang=en'
> split uri=welcome/index.php?lang=en -> uri=welcome/index.php, args=lang=en
> [perdir L:/Webserver/se/internet/] add per-dir prefix: welcome/index.php ->
> L:/Webserver/se/internet/welcome/index.php
> [perdir L:/Webserver/se/internet/] internal redirect with
> L:/Webserver/se/internet/welcome/index.php [INTERNAL REDIRECT]
> init rewrite engine with requested uri
> L:/Webserver/se/internet/welcome/index.php
> pass through L:/Webserver/se/internet/welcome/index.php
>
>
> however i get error message:
> Bad Request
> Your browser sent a request that this server could not understand.
>
> my welcome/index.php really and physically exists inside the folder
> "L:/Webserver/se/internet/"
> so what am i doing wrong ?
> :-(
>
> thx.
>



-- 
Alain
------------------------------------
Windows XP SP3
PostgreSQL 8.2.4 / MS SQL server 2005
Apache 2.2.4
PHP 5.2.4
C# 2005-2008

[users@httpd] close to success with RewriteRule

Posted by Alain Roger <ra...@gmail.com>.
I still no have been successful to make it works.
any idea ?



---------- Forwarded message ----------
From: Alain Roger <ra...@gmail.com>
Date: Tue, Sep 16, 2008 at 7:32 PM
Subject: Re: [users@httpd] close to success with RewriteRule
To: users@httpd.apache.org


this is what i have in my .htaccess file and it seems to be ok according to
log:
#.htaccess file
Options +FollowSymlinks
RewriteEngine on
RewriteRule ^(de|en|fr)/welcome/$    welcome/index.php?lang=$1 [L]

and in the log:
init rewrite engine with requested uri /se_internet/en/welcome/
pass through /se_internet/en/welcome/
[perdir L:/Webserver/se/internet/] add path info postfix:
L:/Webserver/se/internet/en -> L:/Webserver/se/internet/en/welcome/
[perdir L:/Webserver/se/internet/] strip per-dir prefix:
L:/Webserver/se/internet/en/welcome/ -> en/welcome/
[perdir L:/Webserver/se/internet/] applying pattern '^(de|en|fr)/welcome/$'
to uri 'en/welcome/'
[perdir L:/Webserver/se/internet/] rewrite 'en/welcome/' ->
'welcome/index.php?lang=en'
split uri=welcome/index.php?lang=en -> uri=welcome/index.php, args=lang=en
[perdir L:/Webserver/se/internet/] add per-dir prefix: welcome/index.php ->
L:/Webserver/se/internet/welcome/index.php
[perdir L:/Webserver/se/internet/] internal redirect with
L:/Webserver/se/internet/welcome/index.php [INTERNAL REDIRECT]
init rewrite engine with requested uri
L:/Webserver/se/internet/welcome/index.php
pass through L:/Webserver/se/internet/welcome/index.php


however i get error message:
Bad Request
Your browser sent a request that this server could not understand.

my welcome/index.php really and physically exists inside the folder
"L:/Webserver/se/internet/"
so what am i doing wrong ?
:-(

thx.

Re: [users@httpd] close to success with RewriteRule

Posted by Alain Roger <ra...@gmail.com>.
this is what i have in my .htaccess file and it seems to be ok according to
log:
#.htaccess file
Options +FollowSymlinks
RewriteEngine on
RewriteRule ^(de|en|fr)/welcome/$    welcome/index.php?lang=$1 [L]

and in the log:
init rewrite engine with requested uri /se_internet/en/welcome/
pass through /se_internet/en/welcome/
[perdir L:/Webserver/se/internet/] add path info postfix:
L:/Webserver/se/internet/en -> L:/Webserver/se/internet/en/welcome/
[perdir L:/Webserver/se/internet/] strip per-dir prefix:
L:/Webserver/se/internet/en/welcome/ -> en/welcome/
[perdir L:/Webserver/se/internet/] applying pattern '^(de|en|fr)/welcome/$'
to uri 'en/welcome/'
[perdir L:/Webserver/se/internet/] rewrite 'en/welcome/' ->
'welcome/index.php?lang=en'
split uri=welcome/index.php?lang=en -> uri=welcome/index.php, args=lang=en
[perdir L:/Webserver/se/internet/] add per-dir prefix: welcome/index.php ->
L:/Webserver/se/internet/welcome/index.php
[perdir L:/Webserver/se/internet/] internal redirect with
L:/Webserver/se/internet/welcome/index.php [INTERNAL REDIRECT]
init rewrite engine with requested uri
L:/Webserver/se/internet/welcome/index.php
pass through L:/Webserver/se/internet/welcome/index.php


however i get error message:
Bad Request
Your browser sent a request that this server could not understand.

my welcome/index.php really and physically exists inside the folder
"L:/Webserver/se/internet/"
so what am i doing wrong ?
:-(

thx.

On Tue, Sep 16, 2008 at 7:23 PM, Eric Covener <co...@gmail.com> wrote:

> On Tue, Sep 16, 2008 at 1:21 PM, Alain Roger <ra...@gmail.com> wrote:
> > so if i understood well:
> > RewriteBase http://my_ip_address/myroot/
> > RewriteRule ^(de|en|fr)/welcome/$    welcome/index.php?lang=$1 [L]
> >
> > should work ?
>
> No, the RewriteBase is just the url-path (not protocol/host/post)
>
> http://httpd.apache.org/docs/2.2/mod/mod_rewrite.html#rewritebase
>
> welcome/inde.php also has to be valid relative to your htaccess
>
>
> --
> Eric Covener
> covener@gmail.com
>
> ---------------------------------------------------------------------
> 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
>
>


-- 
Alain
------------------------------------
Windows XP SP3
PostgreSQL 8.2.4 / MS SQL server 2005
Apache 2.2.4
PHP 5.2.4
C# 2005-2008

Re: [users@httpd] close to success with RewriteRule

Posted by Eric Covener <co...@gmail.com>.
On Tue, Sep 16, 2008 at 1:21 PM, Alain Roger <ra...@gmail.com> wrote:
> so if i understood well:
> RewriteBase http://my_ip_address/myroot/
> RewriteRule ^(de|en|fr)/welcome/$    welcome/index.php?lang=$1 [L]
>
> should work ?

No, the RewriteBase is just the url-path (not protocol/host/post)

http://httpd.apache.org/docs/2.2/mod/mod_rewrite.html#rewritebase

welcome/inde.php also has to be valid relative to your htaccess


-- 
Eric Covener
covener@gmail.com

---------------------------------------------------------------------
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


Re: [users@httpd] close to success with RewriteRule

Posted by Alain Roger <ra...@gmail.com>.
so if i understood well:
RewriteBase http://my_ip_address/myroot/
RewriteRule ^(de|en|fr)/welcome/$    welcome/index.php?lang=$1 [L]

should work ?



On Tue, Sep 16, 2008 at 7:18 PM, Eric Covener <co...@gmail.com> wrote:

> On Tue, Sep 16, 2008 at 1:11 PM, Alain Roger <ra...@gmail.com> wrote:
> > Hi,
> >
> > i'm closed to succeed with RewriteRule, i just have 1 last issue
> > when i use:
> > RewriteRule ^(de|en|fr)/welcome/$    /welcome/index.php?lang=$1 [L]
> >
> > everything which looks like en/welcome will be rewritten
> > /welcome/index.php?lang=en
> > this works fine... i only have 1 problem. /welcome/... does not exist in
> the
> > current context.
> > it exists only as http://my_ip_address/myroot/welcome/
> >
> > so i tried to use RewriteBase /my_ip_address/myroot/ but without success.
> > how can i redirect each rule to http://my_ip_address/myroot/ ?
> > (without hardcoding each rewriterule as following: RewriteRule
> > ^(de|en|fr)/welcome/$
> > http://my_ip_address/myroot/welcome/index.php?lang=$1 [L])
>
> Your rules are in htaccess. if you drop the leading slash of your
> replacement string, ti will be interpeted as relative to your
> RewriteBase (but your RewriteBase can't just be made up, it has to be
> the URL that got you there)
>
>
>
> --
> Eric Covener
> covener@gmail.com
>
> ---------------------------------------------------------------------
> 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
>
>


-- 
Alain
------------------------------------
Windows XP SP3
PostgreSQL 8.2.4 / MS SQL server 2005
Apache 2.2.4
PHP 5.2.4
C# 2005-2008

Re: [users@httpd] close to success with RewriteRule

Posted by Eric Covener <co...@gmail.com>.
On Tue, Sep 16, 2008 at 1:11 PM, Alain Roger <ra...@gmail.com> wrote:
> Hi,
>
> i'm closed to succeed with RewriteRule, i just have 1 last issue
> when i use:
> RewriteRule ^(de|en|fr)/welcome/$    /welcome/index.php?lang=$1 [L]
>
> everything which looks like en/welcome will be rewritten
> /welcome/index.php?lang=en
> this works fine... i only have 1 problem. /welcome/... does not exist in the
> current context.
> it exists only as http://my_ip_address/myroot/welcome/
>
> so i tried to use RewriteBase /my_ip_address/myroot/ but without success.
> how can i redirect each rule to http://my_ip_address/myroot/ ?
> (without hardcoding each rewriterule as following: RewriteRule
> ^(de|en|fr)/welcome/$
> http://my_ip_address/myroot/welcome/index.php?lang=$1 [L])

Your rules are in htaccess. if you drop the leading slash of your
replacement string, ti will be interpeted as relative to your
RewriteBase (but your RewriteBase can't just be made up, it has to be
the URL that got you there)



-- 
Eric Covener
covener@gmail.com

---------------------------------------------------------------------
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