[SATLUG] Re: When rewrite doesn't
David Kowis
dkowis at shlrm.org
Fri Feb 2 07:25:49 CST 2007
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA512
Mike wrote:
> Okay, I have been able to answer my own questions so far. Now, I have a
> new
> one. First, here's a rewrite rule that works. Don't worry about the crazy
> syntax of the URL I'm writing to. What's imporant is that rewrite is
> applying the rule at the right time.
>
> RewriteRule ^/directory($|/.*) \
> http://127.0.0.1:8080/VirtualHostBase/\
> http/{SERVER_NAME}:80/stuff/VirtualHostRoot/_vh_directory$1 [L,P]
>
> When I visit http://www.someurl.com/directory, the rewrite log shows what
> you would expect to see and I see the expected web page from the other
> server.
>
> (2) init rewrite engine with requested uri /directory
> (3) applying pattern '^/directory($|/.*)' to uri '/directory'
> (2) rewrite /directory ->
> http://127.0.0.1:8080/VirtualHostBase/http/{SERVER_NAME}:80/stuff/VirtualHostRoot/_vh_directory
>
>
> Now, let's say that I would rather that directory/subdir be the path to map
> instead of just plain ol directory. In that case, I'll replace the above
> rule with the following.
>
> RewriteRule ^/directory/subdir($|/.*) \
> http://127.0.0.1:8080/VirtualHostBase/\
> http/{SERVER_NAME}:80/stuff/VirtualHostRoot/_vh_directory/_vh_subdir$1
> [L,P]
>
> Now, when I visit http://www.someurl.com/directory/subdir, the rewrite log
> shows something strange.
>
> (2) init rewrite engine with requested uri /directory/subdir
> (3) applying pattern '^/directory/subdir($|/.*)' to uri '/directory/subdir'
> (1) pass through /directory/subdir
>
> Huh? So, when the pattern is just a single directory, it's able to match.
> When the pattern is multiple directories, it doesn't match. And of course
> the page returned in this case is the classic Apache 404 saying that
> /directory/subdir doesn't exist. So, why does rewrite catch the first
> case,
> but not the second?
Perhaps you need to escape the /'s since it's a regular expression? Just
a guess. Probably wrong since the first one worked.
>
> -Mike
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.6 (GNU/Linux)
iQGVAwUBRcM73cnf+vRw63ObAQowiAwAjw/ef4R76yqXKJDRjSSODn+o50W6oEO9
T8W3pP3w/JIMsJwsIAq3BDBgs15JGQs4mHYAf/PpYK4jvmp+L7k69l0wmLZhqS/H
01uerTlcaPVx5Rymto0UwCdrk+HXuc5Db82v0Jq/A9n02dDa/Xb3DxJ0v4FMOEVm
RTjIUHYENQQRXHLVMZln+QYkK+LwAwDLG1GFeZ83aJApo9jCfapt6BTcXGLLqk7j
/hiVz2wW1iAJSvcx4vmKRW00M222WSUYdR0qSir+q3VRCDe5kWey8lD5wWjwOT6j
24nP+fH2L+QlmXcTZlKJewKYLvXDCfYtDWYOF95LYXb0AOiPAjWKrwjZ2OhmgZMI
IjCS642rt/m+CKf11Wl5n19Z2JQfEORsgQCh9yWWVl4gRHHprtmvPHvMopCNVN4j
GiEb63uaEVQUtWLwKL1zPiyJcAUnp1USOp3FzV6VdMCxX6nzvTmZtAV21BqQ/IHs
FydNm7NXImKlN+Kl69dC9NwKkP6dB0//
=F0KZ
-----END PGP SIGNATURE-----
More information about the SATLUG
mailing list