Forum Moderators: phranque

Message Too Old, No Replies

Does version 2 of Apache break modRewrite rules?

Address bar is changing when it shouldn't

         

MichaelBluejay

6:07 am on Feb 23, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



I recently moved a domain from a server running Apache 1.3 to one running Apache 2.x. Now suddenly my modRewrite isn't working as expected. The address bar is supposed to stay the same, but it's changing. For example, if you browse to <www.domain.com/topic>, the address bar should remain as <www.domain.com/topic>, but instead it's changing to <www.domain.com/content.cgi?topic>.

Here's my code:

RewriteEngine On
RewriteCond %{REQUEST_URI}!\.(cgi¦txt¦css¦gif¦jpg¦pdf¦html¦bv)$
RewriteCond %{REQUEST_URI}!^/admin
RewriteRule (.*) [mydomain.com...] [L]

I thought the fact that I ommitted the [R] flag should mean that the address bar stays the same. My understanding was:

[L] - Address bar stays the same
[R,L] - Address bar changes

But my address bar is changing even though I left off the [R].

Is the syntax different with Apache 2? I didn't think it was, but I'm at a loss to understand why else my code no longer works....

jdMorgan

9:06 pm on Feb 23, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Generally, and despite the documentation, any time you include a full canonical URL as the RewriteRule substitution, an external redirect will be invoked. Unless you specify [R=301], it will be a 302-Moved Temporarily redirect.

Jim

MichaelBluejay

9:13 pm on Feb 23, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



I'm afraid I don't understand what you're saying. How can I redirect to my CGI script without the address bar changing on me?

jdMorgan

9:21 pm on Feb 23, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member




RewriteRule (.*) /content.cgi?$1 [L]

Jim

MichaelBluejay

9:32 pm on Feb 23, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Okay, I get it, and that works great. Thanks!