You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@httpd.apache.org by Phil Wild <ph...@gmail.com> on 2007/12/24 05:26:38 UTC

[users@httpd] Frustrated with rewrite rule, please help...

Hi All,

I am having trouble with my first attempts at using rewrite rules under
apache. I am not sure where I am going wrong and have spent the morning
googling to try and figure this out.

I want to rewrite http://www.site.org/doc/bin/view/TWiki/WebHome so it looks
like http://www.site.org/doc/WebHome where WebHome changes

I have the following in my conf file


ScriptAlias /doc/bin "/opt/twiki/bin"
Alias /doc/pub "/opt/twiki/pub"
Alias /doc "/opt/twiki"

RewriteEngine On
ReWriteLogLevel 9
<Directory "/opt/twiki/bin">
RewriteRule ^doc/([A-Z].*) /doc/bin/view/$1 [PT] [L]
.....

Any clues as to what I am doing wrong?
The error log does not contain any log entries relating to rewriting so I
think I am completely missing the mark...

Cheers

Phil

-- 
Tel: 0400 466 952
Fax: 0433 123 226
email: philwild@gmail.com

Re: [users@httpd] Frustrated with rewrite rule, please help...

Posted by Phil Wild <ph...@gmail.com>.
Thankyou thankyou thankyou

Putting the rules in the right location made all the difference. I learnt
more from your response than I did digging through all the hwoto's I could
find!

Many thanks

Phil


On 26/12/2007, solprovider@apache.org <so...@apache.org> wrote:
>
> On 12/23/07, Phil Wild <ph...@gmail.com> wrote:
> > I am having trouble with my first attempts at using rewrite rules under
> > apache. I am not sure where I am going wrong and have spent the morning
> > googling to try and figure this out.
> >
> > I want to rewrite
> > http://www.example.com/doc/bin/view/TWiki/WebHome so it looks
> > like http://www.example.com/doc/WebHome where WebHome changes
> >
> > I have the following in my conf file:
> > ScriptAlias /doc/bin "/opt/twiki/bin"
> > Alias /doc/pub "/opt/twiki/pub"
> > Alias /doc "/opt/twiki"
> >
> > RewriteEngine On
> > RewriteLogLevel 9
> > <Directory "/opt/twiki/bin">
> > RewriteRule ^doc/([A-Z].*) /doc/bin/view/$1 [PT] [L]
> >
> > Any clues as to what I am doing wrong?
> > The error log does not contain any log entries relating to rewriting so
> I
> > think I am completely missing the mark...
> > Phil
>
> The RewriteRule should begin with a slash.  Multiple flags are
> separated with commas, not by adding additional parameters (which
> should be ignored or cause an error.)
>   RewriteRule ^/doc/([A-Z].*)$ /doc/bin/view/$1 [PT,L]
>
> The Alias commands serve content outside DocumentRoot.  The Alias
> commands belong after the RewriteRules (just for logic.  I do not know
> if the order matters.)  Parameters do not require quotes.  The third
> command makes the second line redundant.
>
> Needing RewriteRule's [L] flag indicates poor design (but is needed
> because sometimes the web administrator does not control the entire
> design.)  For sanity, do not use the same identifier for multiple
> purposes.  You are using "/doc/" as  the external URL path and the
> indicator for internal redirection.  This substitution:
>   /doc/* -> /doc/abc/*
> allows for an infinite loop.  Using:
> /doc/* -> /mydocs/abc/*
> cannot create infinite loops, does not require the [L] flag, and does
> not affect anything outside your control -- just the Alias commands.
>
> None of these commands belong with a Directory section.  httpd cannot
> decide which directory to use until after the Rewrite and Alias
> commands have been processed.
>
> RewriteEngine On
> RewriteLogLevel 9
> RewriteRule ^/doc/([A-Z].*)$ /tdocs/bin/view/$1 [PT]
> RewriteRule ^/doc/(.*)$ /tdocs/$1 [PT]
> ScriptAlias /tdocs/bin /opt/twiki/bin
> Alias /tdocs /opt/twiki
>
> HTH,
> solprovider
>
> ---------------------------------------------------------------------
> 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
>
>


-- 
Tel: 0400 466 952
Fax: 0433 123 226
email: philwild@gmail.com

Re: [users@httpd] Frustrated with rewrite rule, please help...

Posted by so...@apache.org.
On 12/23/07, Phil Wild <ph...@gmail.com> wrote:
> I am having trouble with my first attempts at using rewrite rules under
> apache. I am not sure where I am going wrong and have spent the morning
> googling to try and figure this out.
>
> I want to rewrite
> http://www.example.com/doc/bin/view/TWiki/WebHome so it looks
> like http://www.example.com/doc/WebHome where WebHome changes
>
> I have the following in my conf file:
> ScriptAlias /doc/bin "/opt/twiki/bin"
> Alias /doc/pub "/opt/twiki/pub"
> Alias /doc "/opt/twiki"
>
> RewriteEngine On
> RewriteLogLevel 9
> <Directory "/opt/twiki/bin">
> RewriteRule ^doc/([A-Z].*) /doc/bin/view/$1 [PT] [L]
>
> Any clues as to what I am doing wrong?
> The error log does not contain any log entries relating to rewriting so I
> think I am completely missing the mark...
> Phil

The RewriteRule should begin with a slash.  Multiple flags are
separated with commas, not by adding additional parameters (which
should be ignored or cause an error.)
   RewriteRule ^/doc/([A-Z].*)$ /doc/bin/view/$1 [PT,L]

The Alias commands serve content outside DocumentRoot.  The Alias
commands belong after the RewriteRules (just for logic.  I do not know
if the order matters.)  Parameters do not require quotes.  The third
command makes the second line redundant.

Needing RewriteRule's [L] flag indicates poor design (but is needed
because sometimes the web administrator does not control the entire
design.)  For sanity, do not use the same identifier for multiple
purposes.  You are using "/doc/" as  the external URL path and the
indicator for internal redirection.  This substitution:
   /doc/* -> /doc/abc/*
allows for an infinite loop.  Using:
  /doc/* -> /mydocs/abc/*
cannot create infinite loops, does not require the [L] flag, and does
not affect anything outside your control -- just the Alias commands.

None of these commands belong with a Directory section.  httpd cannot
decide which directory to use until after the Rewrite and Alias
commands have been processed.

RewriteEngine On
RewriteLogLevel 9
RewriteRule ^/doc/([A-Z].*)$ /tdocs/bin/view/$1 [PT]
RewriteRule ^/doc/(.*)$ /tdocs/$1 [PT]
ScriptAlias /tdocs/bin /opt/twiki/bin
Alias /tdocs /opt/twiki

HTH,
solprovider

---------------------------------------------------------------------
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] Frustrated with rewrite rule, please help...

Posted by Phil Wild <ph...@gmail.com>.
Hi Thomas,

Thanks for the reply.

Merry Christmas btw..

Twiki pages all start with an uppercase word (usuallay two words with the
space removed like MerryChristmas) so the [A-Z].* "should" catch it but I
must be doing something wrong as it never does and I don't even see anything
in the logs so I am at a loss as to where the issue is...

Phil


On 25/12/2007, Thomas Hart <to...@coopfed.org> wrote:
>
> Phil Wild wrote:
> > Hi All,
> >
> > I am having trouble with my first attempts at using rewrite rules
> > under apache. I am not sure where I am going wrong and have spent the
> > morning googling to try and figure this out.
> >
> > I want to rewrite http://www.site.org/doc/bin/view/TWiki/WebHome so it
> > looks like http://www.site.org/doc/WebHome
> > <http://www.site.org/doc/WebHome> where WebHome changes
> >
> > I have the following in my conf file
> >
> >
> > ScriptAlias /doc/bin "/opt/twiki/bin"
> > Alias /doc/pub "/opt/twiki/pub"
> > Alias /doc "/opt/twiki"
> >
> > RewriteEngine On
> > ReWriteLogLevel 9
> > <Directory "/opt/twiki/bin">
> > RewriteRule ^doc/([A-Z].*) /doc/bin/view/$1 [PT] [L]
> > .....
> >
> > Any clues as to what I am doing wrong?
> > The error log does not contain any log entries relating to rewriting
> > so I think I am completely missing the mark...
> >
> > Cheers
> >
> > Phil
> >
> > --
> > Tel: 0400 466 952
> > Fax: 0433 123 226
> > email: philwild@gmail.com <ma...@gmail.com>
> I'm no regex expert, but shouldn't
>
> ([A-Z].*)
>
> be
>
> ([A-z].*)
>
> I think you're excluding the lowercase characters
>
> --
> Tom Hart
> IT Specialist
> Cooperative Federal
> 723 Westcott St.
> Syracuse, NY 13210
> (315) 471-1116 ext. 202
> (315) 476-0567 (fax)
>
>
> ---------------------------------------------------------------------
> 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
>
>


-- 
Tel: 0400 466 952
Fax: 0433 123 226
email: philwild@gmail.com

Re: [users@httpd] Frustrated with rewrite rule, please help...

Posted by Thomas Hart <to...@coopfed.org>.
Phil Wild wrote:
> Hi All,
>  
> I am having trouble with my first attempts at using rewrite rules 
> under apache. I am not sure where I am going wrong and have spent the 
> morning googling to try and figure this out.
>  
> I want to rewrite http://www.site.org/doc/bin/view/TWiki/WebHome so it 
> looks like http://www.site.org/doc/WebHome 
> <http://www.site.org/doc/WebHome> where WebHome changes
>  
> I have the following in my conf file
>  
>  
> ScriptAlias /doc/bin "/opt/twiki/bin"
> Alias /doc/pub "/opt/twiki/pub"
> Alias /doc "/opt/twiki"
>  
> RewriteEngine On
> ReWriteLogLevel 9
> <Directory "/opt/twiki/bin">
> RewriteRule ^doc/([A-Z].*) /doc/bin/view/$1 [PT] [L]
> .....
>  
> Any clues as to what I am doing wrong?
> The error log does not contain any log entries relating to rewriting 
> so I think I am completely missing the mark...
>  
> Cheers
>  
> Phil
>
> -- 
> Tel: 0400 466 952
> Fax: 0433 123 226
> email: philwild@gmail.com <ma...@gmail.com>
I'm no regex expert, but shouldn't

([A-Z].*)

be

([A-z].*)

I think you're excluding the lowercase characters

-- 
Tom Hart
IT Specialist
Cooperative Federal
723 Westcott St.
Syracuse, NY 13210
(315) 471-1116 ext. 202
(315) 476-0567 (fax)


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