You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@httpd.apache.org by Mike Zimmerman <ta...@spamcop.net> on 2002/01/18 07:42:19 UTC
Rewrite rule trouble
Good evening,
I'm attempting to create a ruleset that will take care of a problem I'm
having between Tux and Apache. Without going into detail there (its been
painful enough), here is what I'm
trying to make happen:
In order for me to properly route my passed requests from Tux to Apache, I
have to look at the HTTP_HOST variable as follows:
RewriteMap lowercase int:tolower
RewriteRule ^/(.*)$ /var/www/html/${lowercase:%{HTTP_HOST}}/$1
Our directories are created in the Tux virtual hosting fashion, where the
domain - e.g. host.com - is used as the directory, and Tux answers for
both www.host.com and host.com automagically.
The above rewrite works fine for host.com, but when www.host.com is called,
the HTTP_HOST doesn't match up and the directory returned in the rewrite
doesn't exist. I can't seem to figure out how to strip the www. off of the
HTTP_HOST if it exists in order to match things up properly, even after
reading through the rewrite user guides I've found.
I would greatly appreciate any help anyone can provide. My stopgap right
now is symlinks, but that is an ugly hack (can't seem to explain the idea
to the people that upload the files that www.host.com and host.com are
actually the same directory...let alone how to make a symlink).
Thanks,
Mike
---------------------------------------------------------------------
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
For additional commands, e-mail: users-help@httpd.apache.org
RE: Rewrite rule trouble
Posted by Joshua Slive <jo...@slive.ca>.
> From: Daniel Lopez [mailto:daniel@rawbyte.com]
> You may want to look at the article Joshua mentioned earlier:
> http://apache-server.com/tutorials/ATimage-theft.html
> That does not involve rewrite rules
Good idea, but see below for the mod_rewrite way.
> On Fri, Jan 18, 2002 at 08:24:27PM -0600, Jeff Daniels wrote:
> >
> > RewriteCond %{HTTP_REFERER} !^http://www.atomichosts.com/ [NC]
> > RewriteCond %{HTTP_REFERER} !^http://atomichosts.com/ [NC]
> > RewriteRule ^$ - [F]
That "^$" matches only an empty string, which is kind of unlikely if this is
in the main server context. All requests will have at least "/". I think
what you want is "^.*$"
Joshua.
---------------------------------------------------------------------
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
For additional commands, e-mail: users-help@httpd.apache.org
Re: Rewrite rule trouble
Posted by Daniel Lopez <da...@rawbyte.com>.
jeff,
You may want to look at the article Joshua mentioned earlier:
http://apache-server.com/tutorials/ATimage-theft.html
That does not involve rewrite rules
Daniel
On Fri, Jan 18, 2002 at 08:24:27PM -0600, Jeff Daniels wrote:
> Hello Everybody ...
>
> Im new at this list stuff .. but I have a need for help.
>
> Im trying to write a set of rules to prevent hotlinking.
>
>
> I try this
>
> RewriteCond %{HTTP_REFERER} !^http://www.atomichosts.com/ [NC]
> RewriteCond %{HTTP_REFERER} !^http://atomichosts.com/ [NC]
> RewriteRule ^$ - [F]
>
> I've done a ton of variations on this but I cannot get any of them to work
> .. and yes the engine is On.
>
> Any help will be of great value !!!
>
> JEFF
>
>
>
> At 03:33 PM 1/18/2002 -0500, you wrote:
> >Appears to have done the trick. Thanks!
> >
> >At 01:03 PM 1/18/2002 -0500, you wrote:
> >
> >> > From: Mike Zimmerman [mailto:tarmon@spamcop.net]
> >>
> >> > In order for me to properly route my passed requests from Tux to
> >> > Apache, I
> >> > have to look at the HTTP_HOST variable as follows:
> >> >
> >> > RewriteMap lowercase int:tolower
> >> > RewriteRule ^/(.*)$ /var/www/html/${lowercase:%{HTTP_HOST}}/$1
> >> >
> >> > Our directories are created in the Tux virtual hosting fashion, where the
> >> > domain - e.g. host.com - is used as the directory, and Tux answers for
> >> > both www.host.com and host.com automagically.
> >> >
> >> > The above rewrite works fine for host.com, but when www.host.com
> >> > is called,
> >> > the HTTP_HOST doesn't match up and the directory returned in the rewrite
> >> > doesn't exist. I can't seem to figure out how to strip the www.
> >> > off of the
> >> > HTTP_HOST if it exists in order to match things up properly, even after
> >> > reading through the rewrite user guides I've found.
> >> >
> >>
> >>You should be able to use something like:
> >>
> >>RewriteMap lowercase int:tolower
> >>RewriteCond ${lowercast:%{HTTP_HOST}} ^(www\.)?(.*)$
> >>RewriteRule ^/(.*) /var/www/html/%2/$1
> >>
> >>Joshua.
> >>
> >>
> >>---------------------------------------------------------------------
> >>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
> >>For additional commands, e-mail: users-help@httpd.apache.org
> >
> >
> >---------------------------------------------------------------------
> >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
> >For additional commands, e-mail: users-help@httpd.apache.org
> >
>
>
> ---------------------------------------------------------------------
> 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
> For additional commands, e-mail: users-help@httpd.apache.org
>
---------------------------------------------------------------------
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
For additional commands, e-mail: users-help@httpd.apache.org
RE: Rewrite rule trouble
Posted by Jeff Daniels <je...@texaslink.com>.
Hello Everybody ...
Im new at this list stuff .. but I have a need for help.
Im trying to write a set of rules to prevent hotlinking.
I try this
RewriteCond %{HTTP_REFERER} !^http://www.atomichosts.com/ [NC]
RewriteCond %{HTTP_REFERER} !^http://atomichosts.com/ [NC]
RewriteRule ^$ - [F]
I've done a ton of variations on this but I cannot get any of them to work
.. and yes the engine is On.
Any help will be of great value !!!
JEFF
At 03:33 PM 1/18/2002 -0500, you wrote:
>Appears to have done the trick. Thanks!
>
>At 01:03 PM 1/18/2002 -0500, you wrote:
>
>> > From: Mike Zimmerman [mailto:tarmon@spamcop.net]
>>
>> > In order for me to properly route my passed requests from Tux to
>> > Apache, I
>> > have to look at the HTTP_HOST variable as follows:
>> >
>> > RewriteMap lowercase int:tolower
>> > RewriteRule ^/(.*)$ /var/www/html/${lowercase:%{HTTP_HOST}}/$1
>> >
>> > Our directories are created in the Tux virtual hosting fashion, where the
>> > domain - e.g. host.com - is used as the directory, and Tux answers for
>> > both www.host.com and host.com automagically.
>> >
>> > The above rewrite works fine for host.com, but when www.host.com
>> > is called,
>> > the HTTP_HOST doesn't match up and the directory returned in the rewrite
>> > doesn't exist. I can't seem to figure out how to strip the www.
>> > off of the
>> > HTTP_HOST if it exists in order to match things up properly, even after
>> > reading through the rewrite user guides I've found.
>> >
>>
>>You should be able to use something like:
>>
>>RewriteMap lowercase int:tolower
>>RewriteCond ${lowercast:%{HTTP_HOST}} ^(www\.)?(.*)$
>>RewriteRule ^/(.*) /var/www/html/%2/$1
>>
>>Joshua.
>>
>>
>>---------------------------------------------------------------------
>>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
>>For additional commands, e-mail: users-help@httpd.apache.org
>
>
>---------------------------------------------------------------------
>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
>For additional commands, e-mail: users-help@httpd.apache.org
>
---------------------------------------------------------------------
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
For additional commands, e-mail: users-help@httpd.apache.org
RE: Rewrite rule trouble
Posted by Mike Zimmerman <ta...@spamcop.net>.
Appears to have done the trick. Thanks!
At 01:03 PM 1/18/2002 -0500, you wrote:
> > From: Mike Zimmerman [mailto:tarmon@spamcop.net]
>
> > In order for me to properly route my passed requests from Tux to
> > Apache, I
> > have to look at the HTTP_HOST variable as follows:
> >
> > RewriteMap lowercase int:tolower
> > RewriteRule ^/(.*)$ /var/www/html/${lowercase:%{HTTP_HOST}}/$1
> >
> > Our directories are created in the Tux virtual hosting fashion, where the
> > domain - e.g. host.com - is used as the directory, and Tux answers for
> > both www.host.com and host.com automagically.
> >
> > The above rewrite works fine for host.com, but when www.host.com
> > is called,
> > the HTTP_HOST doesn't match up and the directory returned in the rewrite
> > doesn't exist. I can't seem to figure out how to strip the www.
> > off of the
> > HTTP_HOST if it exists in order to match things up properly, even after
> > reading through the rewrite user guides I've found.
> >
>
>You should be able to use something like:
>
>RewriteMap lowercase int:tolower
>RewriteCond ${lowercast:%{HTTP_HOST}} ^(www\.)?(.*)$
>RewriteRule ^/(.*) /var/www/html/%2/$1
>
>Joshua.
>
>
>---------------------------------------------------------------------
>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
>For additional commands, e-mail: users-help@httpd.apache.org
---------------------------------------------------------------------
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
For additional commands, e-mail: users-help@httpd.apache.org
RE: Rewrite rule trouble
Posted by Joshua Slive <jo...@slive.ca>.
> From: Mike Zimmerman [mailto:tarmon@spamcop.net]
> In order for me to properly route my passed requests from Tux to
> Apache, I
> have to look at the HTTP_HOST variable as follows:
>
> RewriteMap lowercase int:tolower
> RewriteRule ^/(.*)$ /var/www/html/${lowercase:%{HTTP_HOST}}/$1
>
> Our directories are created in the Tux virtual hosting fashion, where the
> domain - e.g. host.com - is used as the directory, and Tux answers for
> both www.host.com and host.com automagically.
>
> The above rewrite works fine for host.com, but when www.host.com
> is called,
> the HTTP_HOST doesn't match up and the directory returned in the rewrite
> doesn't exist. I can't seem to figure out how to strip the www.
> off of the
> HTTP_HOST if it exists in order to match things up properly, even after
> reading through the rewrite user guides I've found.
>
You should be able to use something like:
RewriteMap lowercase int:tolower
RewriteCond ${lowercast:%{HTTP_HOST}} ^(www\.)?(.*)$
RewriteRule ^/(.*) /var/www/html/%2/$1
Joshua.
---------------------------------------------------------------------
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
For additional commands, e-mail: users-help@httpd.apache.org