|
Home > Archive > Apache Server configuration support > February 2006 > Dynamic RewriteRule
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
Dynamic RewriteRule
|
|
| CuppaJava 2006-02-17, 10:29 pm |
| Hi,
I had a RewriteRule that has quit processing.
A sample is
RewriteRule ^/o/about\.html$ /o/f3.jsp?A=about [L,R]
this should take www.myurl.com/o/about.html and map it call www.myurl.com/o/f3.jsp?A=about, but it does not.
1. What is my mistake?
2. Can I format a single dynamic rule for all pages matching ^/o/*\.html$
3. Is there a way to display this back out as www.myurl.com/o/mypage.html so that the browser does not see the dynamic redirect?
Thanks,
Mica
| |
| Robert Ionescu 2006-02-17, 10:29 pm |
| CuppaJava wrote:
> RewriteRule ^/o/about\.html$ /o/f3.jsp?A=about [L,R]
If you put this into your <virtualhost...> and there is somewhere the
line "RewriteEngine on" above, it should work. You're getting a "404 not
found" for /o/about.html, or what?
What can you find in your rewrite log (it needs to be activated in
httpd.conf using the directives
RewriteLog logs/rewrite.log
Rewriteloglevel 5
)
> 2. Can I format a single dynamic rule for all pages matching ^/o/*\.html$
Yes. Just change the RegEx to something like
RewriteRule ^/o/([^./]+)\.html$ /o/f3.jsp?A=$1 [L]
> 3. Is there a way to display this back out as www.myurl.com/o/mypage.html so that the browser does not see the dynamic redirect?
Remove the R flag. This forces an external redirection (statuscode 302:
moved temporary).
--
Robert
| |
| CuppaJava 2006-02-17, 10:29 pm |
| I am getting a 404.
Its interesting because I have
RewriteEngine on
RewriteLogLevel 5
RewriteLog c:/apache2/logs/rewrite.txt
And no rewrite text is being written. The file is created...just empty. The rewrite_module is uncommented.
I did get an access error
[Thu Feb 16 13:01:52 2006] [error] [client 127.0.0.1] File does not exist: C:/projects/myurl/web/about.html, referer: http://localhost/index.html
Also, you said the Rewriterule need to be inside of the virtual host as in:
<VirtualHost *:80>
DocumentRoot c:/projects/myurl/web/
RewriteRule ^/o/about\.html$ /o/f3.jsp?A=about [L,R]
</VirtualHost>
Is that correct?
Thank You,
Mica
"Robert Ionescu" <robsiegen@googlemail.com> wrote in message news:dt2hc6$ch9$1@online.de...
> CuppaJava wrote:
>
> If you put this into your <virtualhost...> and there is somewhere the
> line "RewriteEngine on" above, it should work. You're getting a "404 not
> found" for /o/about.html, or what?
>
> What can you find in your rewrite log (it needs to be activated in
> httpd.conf using the directives
>
> RewriteLog logs/rewrite.log
> Rewriteloglevel 5
> )
>
>
> Yes. Just change the RegEx to something like
>
> RewriteRule ^/o/([^./]+)\.html$ /o/f3.jsp?A=$1 [L]
>
>
> Remove the R flag. This forces an external redirection (statuscode 302:
> moved temporary).
>
> --
> Robert
| |
| CuppaJava 2006-02-17, 10:29 pm |
| Robert,
Found it. Had this above, but not IN the virtualhost:
RewriteEngine on ....
That would be helpful to have in the Apache Docs 
Thanks for the GREAT help! I will try the dynamic one line proxy next.
Mica
"Robert Ionescu" <robsiegen@googlemail.com> wrote in message
news:dt2hc6$ch9$1@online.de...
> CuppaJava wrote:
>
> If you put this into your <virtualhost...> and there is somewhere the line
> "RewriteEngine on" above, it should work. You're getting a "404 not found"
> for /o/about.html, or what?
>
> What can you find in your rewrite log (it needs to be activated in
> httpd.conf using the directives
>
> RewriteLog logs/rewrite.log
> Rewriteloglevel 5
> )
>
>
> Yes. Just change the RegEx to something like
>
> RewriteRule ^/o/([^./]+)\.html$ /o/f3.jsp?A=$1 [L]
>
>
> Remove the R flag. This forces an external redirection (statuscode 302:
> moved temporary).
>
> --
> Robert
*** Free account sponsored by SecureIX.com ***
*** Encrypt your Internet usage with a free VPN account from http://www.SecureIX.com ***
| |
| Robert Ionescu 2006-02-17, 10:29 pm |
| CuppaJava wrote:
> Its interesting because I have
>
> RewriteEngine on
>
> RewriteLogLevel 5
>
> RewriteLog c:/apache2/logs/rewrite.txt
To enable logging, you don't need "RewriteEngine on" here, but above the
RewriteRule inside of your <virtualhost...>.
The virtualhost overrides the main server config section, so
"RewriteEngine on" in the main server config section does not activate
RewriteRules for a virtualhost (logging works global).
Your virtualhost should look like
<VirtualHost *:80>
DocumentRoot c:/projects/myurl/web/
RewriteEngine on
#RewriteRule ^/o/about\.html$ /o/f3.jsp?A=about [L,R]
RewriteRule ^/o/([^./]+)\.html$ /o/f3.jsp?A=$1 [L]
</VirtualHost>
--
Robert
| |
| CuppaJava 2006-02-17, 10:29 pm |
| This does not work, it seems to drop the ?A=file
RewriteRule ^/o/([^./]+)\.html$ /o/f3.jsp?A=$1 [L]
Here is a short copy of the rewrite.txt
(2) init rewrite engine with requested uri /o/gloss-auto.html
(3) applying pattern '^/o/([^./]+)\.html$' to uri '/o/gloss-auto.html'
(2) rewrite /o/gloss-auto.html -> /o/f3.jsp?A=gloss-auto
(3) split uri=/o/f3.jsp?A=gloss-auto -> uri=/o/f3.jsp, args=A=gloss-auto
(2) local path result: /o/f3.jsp
(2) prefixed with document_root to C:/projects/aisus/web/o/f3.jsp
(1) go-ahead with C:/projects/aisus/web/o/f3.jsp [OK]
This works, but writes the dynamic URL back out...
RewriteRule ^/o/([^./]+)\.html$ /o/f3.jsp?A=$1 [L,R]
Thanks,
Mica
| |
| Robert Ionescu 2006-02-17, 10:30 pm |
| CuppaJava wrote:
> This does not work, it seems to drop the ?A=file
The uri is split correctly here:
> (3) split uri=/o/f3.jsp?A=gloss-auto -> uri=/o/f3.jsp, args=A=gloss-auto
and the QueryString A=gloss-auto should be available in your script. I
can't see anything wrong here.
--
Robert
|
|
|
|
|