Forum Moderators: phranque
I store all my client's websites in a folder called clients.
A few nifty rewriterules are employed to enable the client to access their sites at [example.com...] instead of having to use [example.com...]
I want to deny access to the second address, so anyone trying to get to [example.com...] gets redirected to another page, without blocking access to the first.
I tried:
RewriteCond %{REQUEST_URI} ^http://.*example.com/clients/.*
RewriteRule ^.*$ splash.php
to no avail,
Any ideas?
Many thanks,
ubcones
[edited by: rogerd at 8:18 pm (utc) on Aug. 12, 2004]
[edit reason] No specifics/URLs, please... [/edit]
RewriteCond %{HTTP_HOST} example\.com
RewriteRule ^/clients/ /splash.php [L]
Jim
I want anyone requesting:
[example.com...]
to be fed:
[example.com...]
but anyone explicitly requesting:
[example.com...]
to be fed:
[example.com...]
Hence I think I need %{REQUEST_URI) not %(HTTP_HOST)
Any ideas?
Seems to be matching whether the address explicity requested is
[example.com...]
or
[example.com...]
Any ideas?
Cheers,
ucbones
p.s. Thanks for the help and patience jdmorgan!
The pattern "/clients/" can't match "/clientnames/", so I suspect the above may be the problem.
Generally, if you do the kind of rewrite you're doing, the client subdirectory - the "ugly" URL always remains accessible in addition to the "nice" URL. That's because you can only use mod_rewrite to "rewrite one way." If you tell the server to rewrite URLa to URLb, then both URLa and URLb will be accessible. If you then try to limit access to URLb, then both will fail. If you redirect URLb back to URLa, then you get a loop.
If you just want to "hide" the client subdirectories from people who've already discovered them, you could simply change the client subdirectory names, rewrite to the new subdirectories instead, and never tell them the new subdirectory URLs. You have to take particular care to make sure that the new subdirectory names are not exposed by an error in your ErrorDocument handling, and that you always use internal rewrites rather than external redirects to access the new subdirectories. In this regard, it's better to get everything tested and working using the old subdirectory names, and then switch them.
There is a solution if you have access to httpd.conf, and that is to set up the client subdirectories as aliases (mod_alias), rather than using rewrites or redirects.
Jim